

<?php $__env->startSection('title','Food Order List'); ?>
<?php $__env->startSection('page-title','Food Order List'); ?>

<?php $__env->startSection('content'); ?>


<div class="card">
   <div class="card-header d-flex justify-content-between align-items-center">
       <h5 class="mb-0">All Order List</h5>
       
   </div>

   <div class="card-body">
       <!-- Filter Form -->
       <form method="GET" class="row g-2 mb-3">
           <div class="col-md-3">
               <input type="text" name="search" class="form-control"
                  value="<?php echo e(request('search')); ?>" placeholder="Search">
           </div>
           <div class="col-md-2">
                <select name="product" class="form-control">
                    <option value="">All Products</option>
            
                    <?php $__currentLoopData = $products; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $product): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($product->id); ?>"
                            <?php echo e(request('product') == $product->id ? 'selected' : ''); ?>>
                            <?php echo e($product->name); ?>

                        </option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>
           <div class="col-md-2">
               <select name="delivery" class="form-control">
                 <option value="">Delivery Status</option>
              
                 <option value="delivered" <?php echo e(request('delivery')=='delivered' ? 'selected' : ''); ?>>
                     Delivered
                 </option>
              
                 <option value="Pending" <?php echo e(request('delivery')=='Pending' ? 'selected' : ''); ?>>
                     Pending
                 </option>
              
                 
               </select>
           </div>
           <div class="col-md-3">
            <input
               type="date"
               class="form-control"
               id="return_date"
               name="return_date"
            >
           </div>
           
           <div class="col-md-2">
               <button class="btn btn-secondary w-100">Filter</button>
           </div>
       </form>
       
        <!-- Products Table -->
       <div class="table-responsive">
         <div id="printTable">
           <table class="table table-bordered align-middle">
               <thead class="table-light">
                    <tr>
                        <th>#</th>
                        <th>Order No</th>
                        <th>Date/Time</th>
                        <th>Customer</th>
                        <th>Food Items</th>
                        <th>Grand Total</th>
                        <th>Paid</th>
                        <th>Balance</th>
                        <th>Status</th>
                        <th width="120">Action</th>
                    </tr>
               </thead>
               <tbody>
                <?php $__currentLoopData = $foodorder; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $order): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                   <tr>
                            <td><?php echo e($loop->iteration); ?></td>

                            <td>#<?php echo e($order->id); ?></td>

                            <td>
                                <?php echo e(\Carbon\Carbon::parse($order->order_date)->format('d M Y')); ?><br>
                                 <?php echo e(\Carbon\Carbon::parse($order->order_date)->format('h:i A')); ?>

                                
                            </td>

                            <td>
                                <strong><?php echo e($order->customer->name ?? '-'); ?></strong><br>
                                <small><?php echo e($order->customer->phone ?? ''); ?></small>
                            </td>

                            <td>
                                <?php $__currentLoopData = $order->details; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $detail): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

                                    <?php if($detail->product && $detail->product->category == 1): ?>

                                        <span class="badge bg-success">
                                            <?php echo e($detail->product->name); ?>

                                        </span><br>
                                        <?php echo e($detail->description); ?>

                                        <br>

                                    <?php endif; ?>
                                    <span>
                                       
                                    </span>

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

                            <td><?php echo e(number_format($order->grand_total,2)); ?></td>

                            <td><?php echo e(number_format($order->paid_amount,2)); ?></td>

                            <td><?php echo e(number_format($order->balance,2)); ?></td>

                            <td>
                                
                                 <?php if($order->order_status =='delivered'): ?>
                                  <span class="badge bg-success">Deliverd</span>
                                  <?php else: ?>
                                    <span class="badge bg-danger">$order->order_status</span>
                                <?php endif; ?>
                                  
                                
                            </td>

                            <td>
                                <a href="<?php echo e(route('admin.Order.detail', $order->id)); ?>"
                                   class="btn btn-sm btn-info">
                                    <i class="fas fa-eye"></i>
                                </a>

                                <a href="<?php echo e(route('admin.Order.update', $order->id)); ?>"
                                   class="btn btn-sm btn-primary">
                                    <i class="fas fa-edit"></i>
                                </a>
                            </td>

                        </tr>
                      
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                 
               </tbody>
           </table>
         </div>
       </div>

       <!-- Pagination -->
      
       <div class="mt-3">
        <div class="pagination-sm">
           <?php echo e($foodorder->links()); ?>

        </div>
       </div>
       
       <button class="btn btn-primary" onclick="printTable()">
            <i class="fas fa-print"></i> Print
       </button>
     </div>
</div>


<?php $__env->stopSection(); ?>

<?php $__env->startPush('js'); ?>
<script>

function printTable() {
    var printContents = document.getElementById('printTable').innerHTML;
    var originalContents = document.body.innerHTML;

    document.body.innerHTML = printContents;
    window.print();
    document.body.innerHTML = originalContents;

    location.reload();
}
</script>

</script>
<?php $__env->stopPush(); ?>
<?php echo $__env->make('Admin.layout.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/xtradezone/public_html/alifoods.xtradezone.com/alifoods/resources/views/Admin/partials/foodorders.blade.php ENDPATH**/ ?>