<?php $__env->startSection('content'); ?>
<?php $input['date_range'] = !empty($input['date_range']) ? $input['date_range'] : null; 
$currency =  setting_by_key("currency");
?>
<link href="<?php echo e(url('assets/css/plugins/datapicker/datepicker3.css')); ?>" rel="stylesheet">

 <link href="<?php echo e(url('assets/css/plugins/daterangepicker/daterangepicker-bs3.css')); ?>" rel="stylesheet">

<div class="wrapper wrapper-content animated fadeInRight">
            <div class="row">
                <div class="col-lg-8">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5><?php echo app('translator')->getFromJson('reports.sales'); ?></h5>
                        
                    </div>
                    <div class="ibox-content">

                        <table class="table">
                            <thead>
                           <tr>
                            <th>#</th>
                            <th><?php echo app('translator')->getFromJson('reports.sales_date'); ?></th>
							<th><?php echo app('translator')->getFromJson('reports.amount'); ?></th>
                            <th><?php echo app('translator')->getFromJson('reports.discount'); ?></th>
                            <th><?php echo app('translator')->getFromJson('reports.total_amount'); ?></th>
                            <th></th>
                        </tr>
                            </thead>
                            <tbody>
							<?php $total_discount=0;$total_amount = 0; ?>
                    <?php if(!empty($sales)): ?>
                        <?php $__empty_1 = true; $__currentLoopData = $sales; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $sale): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                            <tr>
                                <td><?php echo e($key + 1); ?></td>
                               <td><?php echo e(date('d F Y' , strtotime($sale->created_at))); ?></td>
                                
							   <td><?php echo e($currency); ?> <?php echo e($sale->amount); ?></td>
                                <td><?php echo e($currency); ?> <?php echo e($sale->discount); ?></td>
                                <td><?php echo e($currency); ?> <?php echo e($sale->amount); ?></td>
                                <td>
                                    <a href="<?php echo e(url('reports/sales/' . $sale->id)); ?>" class="btn btn-primary btn-xs pull-right"><?php echo app('translator')->getFromJson('common.show'); ?></a>
                                </td>
                            </tr>
							<?php $total_amount += $sale->amount; ?>
							<?php $total_discount += $sale->discount; ?>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                            <?php echo $__env->make('backend.partials.table-blank-slate', ['colspan' => 5], array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
                        <?php endif; ?>
                    <?php endif; ?>
                    </tbody>
					
						<tr>
                                <th><?php echo e(count($sales)); ?></th>
                                <td></td>
                                
							    <th><?php echo e($currency); ?> <?php echo e($total_amount); ?></th>
                                <th><?php echo e($currency); ?> <?php echo e($total_discount); ?></th>
                                <th><?php echo e($currency); ?> <?php echo e($total_amount - $total_discount); ?></th>
                                <th> Total Amount : </th>
                                <th><?php echo e($currency); ?> <?php echo e($total_amount - $total_discount); ?></th>
                               
                            </tr>
							
							
                        </table>

                    </div>
                </div>
            </div>
            
            <div class="col-md-4">
            <div class="panel panel-default">
                 <div class="ibox-title">
                        <h5><?php echo app('translator')->getFromJson('reports.date_range'); ?></h5>
                        
                    </div>
                 <div class="ibox-content">    
                    <form id="formSubmit" action="<?php echo e(url('reports/sales')); ?>" method="GET">
                        <div class="form-group">
                            <label for="price"><?php echo app('translator')->getFromJson('reports.date_range'); ?></label>
                            <select class="form-control" id="date-range" name="date_range">
                                <option><?php echo app('translator')->getFromJson('reports.select_date_range'); ?></option>
                                <option value="today" <?php echo e(($input['date_range'] == 'today') ? 'selected="selected"' : ''); ?>><?php echo app('translator')->getFromJson('reports.today'); ?></option>
                                <option value="current_week" <?php echo e(($input['date_range'] == 'current_week') ? 'selected="selected"' : ''); ?>><?php echo app('translator')->getFromJson('reports.this_week'); ?></option>
                                <option value="current_month" <?php echo e(($input['date_range'] == 'current_month') ? 'selected="selected"' : ''); ?>><?php echo app('translator')->getFromJson('reports.this_month'); ?></option>
                                <option value="custom_date" <?php echo e(($input['date_range'] == 'custom_date') ? 'selected="selected"' : ''); ?>><?php echo app('translator')->getFromJson('reports.custom_date'); ?></option>
								
								
                            </select>
                        </div>
						
						<div class="form-group" id="data_5">
                                <label class="font-noraml"><?php echo app('translator')->getFromJson('reports.range_select'); ?></label>
                                <div class="input-daterange input-group" id="datepicker">
                                    <input type="text" class="input-sm form-control" name="start" value="<?php echo e((!empty($input['start']) and $input['start'] !=  '') ? $input['start'] : ''); ?>"/>
                                    <span class="input-group-addon">to</span>
                                    <input type="text" class="input-sm form-control" name="end" value="<?php echo e((!empty($input['end']) and $input['end'] !=  '') ? $input['end'] : ''); ?>" />
                                </div>
                            </div>

                        

                        <div class="form-group">
						<input type="hidden" name="pdf" id="pdf" value="" />
                            <button type="submit" class="btn btn-primary"><?php echo app('translator')->getFromJson('reports.search'); ?></button>
							<a href="javascript:void(0);" class="btn btn-warning" id="DownloadPDF"> <?php echo app('translator')->getFromJson('reports.download_pdf'); ?> </a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        
    </div>
</div>

<script> 
	$("body").on("click" , "#SubmitSearch" , function() {
		$("#pdf").val("");
		$("#formSubmit").submit();
	});
	
	$("body").on("click" , "#DownloadPDF" , function() {
		$("#pdf").val("yes");
		$("#formSubmit").submit();
	});
</script>


	<!-- <?php echo app('translator')->getFromJson('reports.date_range'); ?> use moment.js same as full calendar plugin -->
	
	 <!-- Data picker -->
   <script src="<?php echo e(url('assets/js/plugins/datapicker/bootstrap-datepicker.js')); ?>"></script>

    <script src="<?php echo e(url('assets/js/plugins/fullcalendar/moment.min.js')); ?>"></script>
    <script src="<?php echo e(url('assets/js/plugins/daterangepicker/daterangepicker.js')); ?>"></script>
	
			<script> 
			$('#data_5 .input-daterange').datepicker({
                keyboardNavigation: false,
                forceParse: false,
                autoclose: true
            });
			</script>
			
			


<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>