<?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('common.sales'); ?></h5>
                        
                    </div>
                    <div class="ibox-content">

                        <table class="table">
                            <thead>
                           <tr>
                            <th>#</th>
                            <th><?php echo app('translator')->getFromJson('reports.sales_by'); ?></th>
							<th><?php echo app('translator')->getFromJson('reports.total_amount'); ?></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 if(!empty($sale->user->name)): ?> <?php echo e($sale->user->name); ?> <?php else: ?> -- Online Orders -- <?php endif; ?></td>
                                <td><?php echo e($currency); ?> <?php echo e($sale->total_amount); ?></td>
                                
                            </tr>
							<?php $total_amount += $sale->total_amount; ?>
                        <?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>
                                <th> <?php echo app('translator')->getFromJson('reports.total_sales'); ?> </th>
                                
							    <th><?php echo e($currency); ?> <?php echo e($total_amount); ?></th>
                               
                            </tr>
							
							
                        </table>

						<div class="text-right">
	<a href="javascript:void(0);"  class="btn btn-sm btn-info export"><?php echo app('translator')->getFromJson('reports.download_csv'); ?></a>
	<a target="_blank" href="<?php echo e(url('email/staff_sold?pdf=yes')); ?>" class="btn btn-sm btn-warning" id="DownloadPDF"> <?php echo app('translator')->getFromJson('reports.download_pdf'); ?> </a>
</div>

                   
					

<script> 
$(document).ready(function () {

    function exportTableToCSV($table, filename) {

        var $rows = $table.find('tr:has(th,td)').not("#notslect"),

            // Temporary delimiter characters unlikely to be typed by keyboard
            // This is to avoid accidentally splitting the actual contents
            tmpColDelim = String.fromCharCode(11), // vertical tab character
            tmpRowDelim = String.fromCharCode(0), // null character

            // actual delimiter characters for CSV format
            colDelim = '","',
            rowDelim = '"\r\n"',

            // Grab text from table into CSV formatted string
            csv = '"' + $rows.map(function (i, row) {
                var $row = $(row),
                    $cols = $row.find('td,th');

                return $cols.map(function (j, col) {
                    var $col = $(col),
                        text = $col.text();

                    return text.replace(/"/g, '""'); // escape double quotes

                }).get().join(tmpColDelim);

            }).get().join(tmpRowDelim)
                .split(tmpRowDelim).join(rowDelim)
                .split(tmpColDelim).join(colDelim) + '"',

            // Data URI
            csvData = 'data:application/csv;charset=utf-8,' + encodeURIComponent(csv);

        $(this)
            .attr({
            'download': filename,
                'href': csvData,
                'target': '_blank'
        });
    }

    // This must be a hyperlink
    $(".export").on('click', function (event) {
        // CSV
       var name = $(".no-margin-bottom").html();
        exportTableToCSV.apply(this, [$('.export_table'),'staff_sold.csv']);
        
        // IF CSV, don't do event.preventDefault() or return false
        // We actually need this to be a typical hyperlink
    });
});
		
	</script>
	
	
                    </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 action="<?php echo e(url('reports/staff_sold')); ?>" 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">
                            <button type="submit" class="btn btn-primary">Search</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        
    </div>
</div>
	<!-- <?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(); ?>