<?php $__env->startSection('main-container'); ?>
<main id="main" class="main">
<?php echo $__env->make('cdn', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

<div class="row page-titles mx-0">

    <div class="col-sm-6 p-md-0">

        <div class="breadcrumb-range-picker">

             <h3>Orders</h3>

        </div>

    </div>

    <div class="col-sm-6 p-md-0 justify-content-sm-end mt-2 mt-sm-0 d-flex">

        <a href="<?php echo e(route('/')); ?>" class="btns primary-btn ml-4">

           <span class="btn-icon-left" style="color: white">Back</span>

       </a>

   </div>

</div>

<div class="container-fluid" style="margin-top: 15px">

    <?php echo $__env->make('flash_msg', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

    <div class="row">

        <div class="col-12">

            <div class="card">

                <div class="card-body">

                    <form action="<?php echo e(route('user_by_search_order.search')); ?>" method="get">
                        <div class="row">
                            <div class="form-group col-md-4">
                                <select class="form-control" name="user_id">
                                    <option value="">Select User</option>
                                     <?php $__currentLoopData = $users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $user): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($user->id); ?>" <?php echo e($user->id == $request->user_id ? 'selected' : ''); ?>><?php echo e($user->name); ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                            </div>

                            <div class="form-group col-md-4">
                                <select class="form-control" name="customer_id">
                                    <option value="">Select Employee</option>
                                     <?php $__currentLoopData = $users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $user): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($user->id); ?>" <?php echo e($user->id == $request->customer_id ? 'selected' : ''); ?>><?php echo e($user->name); ?></option>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </select>
                            </div>
                            <div class="col-md-2 form-group">
                                <input type="submit" class="btns primary-btn" value="Filter">
                            </div>
                        </div>
                    </form>

                    <hr>

                    <div class="table-responsive">

                        <table class="table table-border table-hover table-sm" >
                            <thead>

                                <tr>

                                    <th>#</th>

                                    <th>CREATED BY</th>

                                    <th>CUSTOMER NAME</th>

                                    <th>AMOUNT</th>

                                    <th>DATE</th>

                                    <th>ORDER STATUS</th>

                                    <th class="text-right">Action</th>

                                </tr>

                            </thead>


                            <tbody>

                                <?php if(!empty($orders)): ?>

                                <?php $__currentLoopData = $orders; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

                                <tr>

                                    <td><?php echo e(++$key); ?></td>

                                    <td><?php echo e($value->User->name ?? 'N/A'); ?></td>

                                    <td><?php echo e($value->Customer->name ?? 'N/A'); ?></td>

                                    <td>₹ <?php echo e($value->amount); ?> /-</td>

                                    <td><?php echo e($value->created_at->format('d-m-Y')); ?></td>

                                    <td>
                                        <?php if($value->status=='1'): ?>

                                            <a href="<?php echo e(url('orderactive/'.$value->id)); ?>">

                                                <button class="btns success-btn">Accepted</button>

                                            </a>
                                            <?php else: ?>
                                            <a href="<?php echo e(url('orderactive/'.$value->id)); ?>">

                                                <button class="btn btn-danger">Pending</button>

                                            </a>

                                            <?php endif; ?>
                                    </td>
                                    <td class="text-right">

                                        <a href="<?php echo e(route('order.view',encrypt($value->id))); ?>">
                                        <button type="button" class="btns success-btn btn-sm" title="View More" alt="View More"><i class="fas fa-eye"></i> 
                                        </button>
                                        </a>


                                         <a href="<?php echo e(route('order.delete',encrypt($value->id))); ?>" onclick="return confirm('Are you sure?')">
                                        <button type="button" class="btns success-btn btn-sm" title="Delete" alt="Delete"><i class="fas fa-trash-alt"></i>
                                        </button>
                                        </a>



                                    </td>

                                    </tr>

                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                                    <?php if($orders->count() == 0): ?>

                                    <tr class="text-center">

                                        <td colspan="6">No Orders to display .</td>

                                    </tr>

                                    <?php endif; ?>

                                <?php endif; ?>

                            </tbody>

                            <tfoot>

                                <tr>
                                    <th>#</th>

                                    <th>Created By</th>

                                    <th>Customer Name</th>

                                    <th>Amount</th>

                                    <th>Date</th>

                                    <th>Order Status</th>

                                    <th class="text-right">Action</th>

                                </tr>


                            </tfoot>

                        </table>

                    </div>

                     <div class="text-left float-left mt-1">

                           <p>Displaying <?php echo e($orders->count()); ?> of <?php echo e($orders->total()); ?> Add Order.</p>

                    </div>


                    <div class="pagination">
                        <ul class="pagination-list">
                            <?php if($orders->currentPage() > 1): ?>
                                <li class="pagination-item">
                                    <a href="<?php echo e($orders->appends(request()->all())->previousPageUrl()); ?>" class="pagination-link">&lt;</a>
                                </li>
                            <?php endif; ?>

                            <?php if($orders->currentPage() > 3): ?>
                                <li class="pagination-item">
                                    <a href="<?php echo e($orders->appends(request()->all())->url(1)); ?>" class="pagination-link">1</a>
                                </li>
                                <li class="pagination-item disabled">
                                    <span class="pagination-link">...</span>
                                </li>
                            <?php endif; ?>

                            <?php $__currentLoopData = range(max(1, $orders->currentPage() - 2), min($orders->lastPage(), $orders->currentPage() + 2)); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $page): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <li class="pagination-item <?php echo e($page == $orders->currentPage() ? 'active' : ''); ?>">
                                    <a href="<?php echo e($orders->appends(request()->all())->url($page)); ?>" class="pagination-link"><?php echo e($page); ?></a>
                                </li>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                            <?php if($orders->currentPage() < $orders->lastPage() - 2): ?>
                                <li class="pagination-item disabled">
                                    <span class="pagination-link">...</span>
                                </li>
                                <li class="pagination-item">
                                    <a href="<?php echo e($orders->appends(request()->all())->url($orders->lastPage())); ?>" class="pagination-link"><?php echo e($orders->lastPage()); ?></a>
                                </li>
                            <?php endif; ?>

                            <?php if($orders->hasMorePages()): ?>
                                <li class="pagination-item">
                                    <a href="<?php echo e($orders->appends(request()->all())->nextPageUrl()); ?>" class="pagination-link">&gt;</a>
                                </li>
                            <?php endif; ?>
                        </ul>
                    </div>

                </div>

            </div>

        </div>

    </div>

</div>
</main><!-- End #main -->
 <?php $__env->stopSection(); ?>

<?php echo $__env->make('frontend.layouts.main', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/vinecork/public_html/webdev/DATA/resources/views/order/index.blade.php ENDPATH**/ ?>