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

<?php $__env->startPush('css'); ?>
    	<link rel="stylesheet" href="<?php echo e(asset('backend/plugins/select2.min.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>Invoices 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=" search-section">
                                <div class="col-sm-1">
                                    <form action="" id="searchForm" method="Get" autocomplete="off">
                                        <select class="form-control" name="show" id="show" onchange="if (this.value) window.location.href='?show='+this.value">
                                            <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>
                                    </form>
                                </div>
                                <div class="col-sm-2">
                                    <div class="input-group">
                                        <input type="text" id="myInput" class="form-control" placeholder="Filter Row" autocomplete="off">
                                        <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>
                                <div class="col-sm-2">
    								<form action="" id="categoryForm" method="Get" autocomplete="off">
    									<select class="form-control select2" name="show" id="category" onchange="if (this.value) window.location.href='?category='+this.value">
    										<option value=""> All Category </option>
    										<?php $__currentLoopData = $categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ct): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
    										<option value="<?php echo e($ct->id); ?>" <?php echo e(request()->category == $ct->id ? 'selected' : ''); ?> ><?php echo e($ct->name); ?></option>
    										<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    									</select>
    								</form>
    							</div>
                                <div class="col-sm-2"></div>
                                <form action="<?php echo e(route('sales.invoice_search')); ?>" id="" method="Post" autocomplete="off">
                                    <?php echo e(method_field('Get')); ?>

                                    <div class="col-sm-2">
                                        <select class="form-control" name="column" id="column">
                                            <option value="name" <?php echo request()->column == 'name' ? 'selected' : ''; ?> >Customer Name</option>
                                            <option value="phone" <?php echo request()->column == 'phone' ? 'selected' : ''; ?> >Phone Number</option>
                                            <option value="invoice_no" <?php echo request()->column == 'invoice_no' ? 'selected' : ''; ?> >Invoice No</option>
                                            <option value="grand_total_price" <?php echo request()->column == 'grand_total_price' ? 'selected' : ''; ?> >Total Price</option>
                                            <option value="sale_date" <?php echo request()->column == 'sale_date' ? 'selected' : ''; ?> >Sales date</option>
                                        </select>
                                    </div>
                                    <div class="col-sm-3">
                                        <div class="input-group">
                                            <input type="text" id="search_value" name="search_value" class="form-control" placeholder="Search" value="<?php echo e(request()->search_value); ?>" >
                                            <span class="input-group-btn">
                                                <button type="submit" 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  class="table table-condensed table-bordered table-hover">
                                    <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>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><a href="<?php echo e(url('csrs').'?customer_id='.$pc->customer_id.'&report_type=Statement'); ?>" target="_blank"><?php echo e($pc->customer->name); ?></a> </td>
                                            <td><a href="<?php echo e(url('csrs').'?customer_id='.$pc->customer_id.'&report_type=Invoice'); ?>" target="_blank"><?php echo e($pc->invoice_no); ?></a></td>
                                            <td><a href="<?php echo e(url('csrs').'?customer_id='.$pc->customer_id.'&report_type=Product'); ?>" target="_blank"><?php echo e($pc->grand_total_price); ?></a> </td>
                                            <td><a href="<?php echo e(url('csrs').'?customer_id='.$pc->customer_id.'&report_type=Record'); ?>" target="_blank"> <?php echo e($pc->payment); ?></a></td>
                                            <td><a href="<?php echo e(url('csrs').'?customer_id='.$pc->customer_id.'&report_type=Sales_Due'); ?>" target="_blank"> <?php echo e($pc->due_amount); ?></a></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'); ?>
<script src="<?php echo e(asset('backend/plugins/select2.min.js')); ?>"></script>
<script>
    $(document).ready(function() {
	    // select2 section
        $('.select2').select2()	;
	});
</script>
<?php $__env->stopPush(); ?>
<?php echo $__env->make('backend.layouts.master', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>