<?php $__env->startSection('title','Sales List'); ?>

<?php $__env->startPush('css'); ?>
   
<?php $__env->stopPush(); ?>
<!-- page content -->
<?php $__env->startSection('content'); ?>
    <div class="right_col" role="main">
        <div class="">
            <div class="clearfix"></div>
            <?php if(Session::has('success')): ?>
                <div class="alert alert-success">
                    <?php echo e(Session::get('success')); ?>

                </div>
            <?php endif; ?>
            <?php if(Session::has('error')): ?>
                <div class="alert alert-danger">
                    <?php echo e(Session::get('error')); ?>

                </div>
            <?php endif; ?>
            <div class="row">
                <div class="col-md-12 col-sm-12 col-xs-12">
                    <div class="x_panel">
                        <div class="x_title">
                            <h2>Sales List</h2>
                            <ul class="nav navbar-right panel_toolbox">
                                <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                                </li>
                                <li class="dropdown">
                                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
                                    <ul class="dropdown-menu" role="menu">
                                        <li><a href="#">Settings 1</a>
                                        </li>
                                        <li><a href="#">Settings 2</a>
                                        </li>
                                    </ul>
                                </li>
                                <li><a class="close-link"><i class="fa fa-close"></i></a>
                                </li>
                            </ul>
                            <div class="clearfix"></div>
                        </div>
                        <div class="">
                            <div class="row search-section">
                                <form action="<?php echo e(route('sales.list')); ?>" id="searchForm" method="Get">
                                    <div class="col-sm-2">
                                        <select class="form-control" name="show" id="show">
                                            <option value="<?php echo e($sales->count()); ?>"><?php echo e($sales->count()); ?></option>
                                            <?php $__currentLoopData = explode(",",setting()->pdl); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $d): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
    										<option value="<?php echo e($d); ?>"><?php echo e($d); ?></option>
    										<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    										<option value="<?php echo e($sales->total()); ?>">All</option>
                                        </select>
                                    </div>
                                    <div class="col-sm-7"></div>
                                    <div class="col-sm-3">
                                        <div class="input-group">
                                            <input type="text" id="myInput" class="form-control" placeholder="Search">
                                            <span class="input-group-btn">
                                                <button type="button" class="btn btn-primary">
                                                <span class="ace-icon fa fa-search icon-on-right bigger-110"></span></button>
                                            </span>
                                        </div>
                                    </div>
                                </form> 
                            </div>
                            <div class="table-content x_content table-responsive">
                                <table width="100%" class="table table-condensed table-bordered table-hover" id="categorytable">
                                    <thead>
                                    <tr class="bg-primary">
                                        <th>SL</th>
                                        <th>Date</th>
                                        <th>Customer</th>
                                        <th>Invoice</th>
                                        <th>Total</th>
                                        <th>Payment</th>
                                        <th>Due</th>
                                        <th>Status</th>
                                        <th>Action</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <?php $__currentLoopData = $sales; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $i=>$pc): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <tr>
                                            <td> <?php echo e($i+1); ?></td>
                                            <td> <?php echo e(date('d-m-Y',strtotime($pc->sale_date))); ?></td>
                                            <td><?php echo e($pc->customer->name); ?> </td>
                                            <td> <?php echo e($pc->invoice_no); ?></td>
                                            <td><?php echo e($pc->grand_total_price); ?> </td>
                                            <td> <?php echo e($pc->payment); ?></td>
                                            <td> <?php echo e($pc->due_amount); ?></td>
                                            <td> <span class="label <?php echo e($pc->sale_type == 'Sold' ? 'label-success' : 'label-warning'); ?> "> <?php echo e($pc->sale_type); ?></span></td>
                                            <td>
                                              <a href="<?php echo e(route('sales.print',$pc->id)); ?>" class="btn-xs btn-primary" target="_blank"><i class="fa fa-print fa-x"></i></a>  
                                              <a href="<?php echo e(route('sales.show',$pc->id)); ?>" class="btn-xs btn-primary"><i class="fa fa-eye fa-x"></i></a>  
                                            </td>
                                        </tr>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </tbody>
                                    <tfoot>
                                    <tr>
                                        <td colspan="4">Grand Total</td>
                                        <td><?php echo e($sales->sum('grand_total_price')); ?></td>
                                        <td><?php echo e($sales->sum('payment')); ?></td>
                                        <td><?php echo e($sales->sum('due_amount')); ?></td>
                                        <td></td>
                                    </tr>
                                    </tfoot>
                                </table>
                            </div>
                        </div>
                        <div class="text-center">
                            <?php echo e($sales->links()); ?>

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- /page content -->
<?php $__env->stopSection(); ?>
<?php $__env->startPush('js'); ?>

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