<?php $__env->startSection('title'); ?>
   Customer Management
<?php $__env->stopSection(); ?>
<?php $__env->startSection('css'); ?>

<?php $__env->stopSection(); ?>
<!-- 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>Manage Customer
                                 <a href="<?php echo e(route('account.cpi')); ?>" class="btn btn-xs btn-primary"> Payment</a>
                                  <a href="<?php echo e(route('customer.create')); ?>" class="btn btn-xs btn-primary">New Customer</a>
                             </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">
                                <div class="col-sm-2">
                                    <form action="<?php echo e(route('customer.list')); ?>" id="searchForm" method="Get">
                                        <select class="form-control" name="show" id="show">
                                            <option value="<?php echo e($customers->count()); ?>"><?php echo e($customers->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($customers->total()); ?>">All</option>
                                        </select>
                                    </form>
                                </div>
                                <div class="col-sm-3">
                                    <div class="input-group">
                                        <input type="text" id="myInput" class="form-control" placeholder="Filter Row">
                                        <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"></div>
                                <form action="<?php echo e(route('customer.customer_search')); ?>" id="" method="Post">
                                    <?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="email" <?php echo request()->column == 'email' ? 'selected' : ''; ?> >Email </option>
                                            <option value="address" <?php echo request()->column == 'address' ? 'selected' : ''; ?> >Address</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="x_content table-responsive">
                                <table class="table table-condensed table-bordered " id="">
                                    <thead>
                                    <tr class="bg-primary">
                                        <th>SL</th>
                                        <th>Customer</th>
                                        <th>Phone</th>
                                        <th>Email</th>
                                        <th>Address</th>
                                        <th>Total Price</th>
                                        <th>Total Payment</th>
                                        <th>Total Due</th>
                                        <th>Action</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <?php $__currentLoopData = $customers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $i=>$pc): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <tr>
                                            <th> <?php echo e($i+1); ?></th>
                                            <td> <?php echo e($pc->name); ?></td>
                                            <td> <?php echo e($pc->phone); ?></td>
                                            <td> <?php echo e($pc->email); ?></td>
                                            <td> <?php echo e($pc->address); ?></td>
                                            <td> <?php echo e($pc->sales->sum('grand_total_price')); ?></td>
                                            <td> <?php echo e($pc->sales->sum('payment')); ?></td>
                                            <td> <?php echo e($pc->sales->sum('due_amount')); ?></td>
                                            <td>
                                                <div class="row">
                                                    <div class="col-md-4">
                                                        <a href="<?php echo e(route('customer.edit',$pc->id)); ?>" class=" btn-xs btn-warning"><i class="fa fa-edit"></i></a>
                                                    </div>
                                                    <div class="col-md-4">
                                                    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('customer-delete')): ?>
                                                        <form action="<?php echo e(route('customer.delete' ,$pc->id)); ?>" method="post">
                                                            <input type="hidden" name="_method" value="DELETE">
                                                            <?php echo e(csrf_field()); ?>

                                                            <button type="submit" class="btn btn-xs btn-danger" onclick="return confirm('are you sure to delete?')" ><i class="fa fa-trash-o"></i> Delete</button>
                                                        </form>
                                                    <?php endif; ?>
                                                    </div>
                                                </div>
                                            </td>
                                        </tr>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </tbody>
                                </table>
                            </div>
                             <div class="text-center">
								<?php echo e($customers->links()); ?>

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

<?php $__env->startSection('script'); ?>
    <script type="text/javascript" src="<?php echo e(asset('backend/plugins/jquery.dataTables.min.js')); ?>"></script>
    <script type="text/javascript">
        $(document).ready(function() {
            $('#categorytable').DataTable();
        });
    </script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('backend.layouts.master', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>