<?php echo $__env->make('admin::layouts.header', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
<?php
use App\Models\CustomerDetails;
?>
<main id="main-container">
        <!-- Hero -->
        <div class="bg-body-light">
          <div class="content content-full">
            <div class="d-flex flex-column flex-sm-row justify-content-sm-between align-items-sm-center">
              <h1 class="flex-grow-1 fs-3 fw-semibold my-2 my-sm-3">All Orders</h1>
              <nav class="flex-shrink-0 my-2 my-sm-0 ms-sm-3" aria-label="breadcrumb">
                <ol class="breadcrumb">
                  <li class="breadcrumb-item">Dashboard</li>
                  <li class="breadcrumb-item">Sales</li>
                  <li class="breadcrumb-item active" aria-current="page">All Orders</li>
                </ol>
              </nav>
            </div>
          </div>
        </div>
        <!-- END Hero -->

        <!-- Page Content -->
        <div class="content">
          <!-- Your Block -->
          <div class="block block-rounded">
            <div class="block-header block-header-default">
              <h3 class="block-title">All Orders</h3>
            </div>
            <div class="block-content">
            <?php if(Session::has('success')): ?> <div class="alert alert-success mt-2 mb-2"><?php echo Session::get('success')  ?></div><?php endif; ?>
            <?php if(Session::has('fail')): ?> <div class="alert alert-danger mt-2 mb-2"><?php echo e(Session::get('fail')); ?></div><?php endif; ?>
            <table  id="example" class="custom-datatable-no-export display responsive nowrap" style="width:100%">
                <thead>
                  <tr>
                  <th>Order No</th>
                  <th>Customer</th>
                  <!-- <th>Order Date</th>
                  <th>Delivery Date</th>
                  <th>Price Method</th> -->
                  <th>Total</th>
                  <th>Paid By Cash</th>
                  <th>Paid By Card</th>
                  <th>Paid Online</th>
                  <th>Credit</th>
                  <th>Credit Paid</th>
                  <!-- <th>Card Ref No</th>  -->
                  <!-- <th>status</th> -->
                  <th>Actions</th>
                  </tr>
                </thead>
                <tbody>
                <?php foreach($orders as $orders) {
                    $name = CustomerDetails::withTrashed()->where('user_id', $orders->customer)->value('customer_name');
                ?>
                  <tr>
                    <td class="fw-semibold">
                      <?php echo e($orders->sales_order_number); ?>

                    </td>
                    <td class="fw-semibold">
                      <?php echo e($name ?? 'Cash'); ?>

                    </td>
                    <td class="fw-semibold">
                      <?php echo e(number_format($orders->total)); ?>

                    </td>
                    <td class="fw-semibold">
                      <?php echo e(number_format($orders->cash_paid_amount ?? 0)); ?>

                    </td>
                    <td class="fw-semibold">
                      <?php echo e(number_format($orders->card_paid_amount ?? 0)); ?>

                    </td>
                    <td class="fw-semibold">
                      <?php echo e(number_format($orders->online_amount ?? 0)); ?>

                    </td>
                    <td class="fw-semibold">
                      <?php echo e(number_format($orders->credit_amount ?? 0)); ?>

                    </td>
                    <td class="fw-semibold">
                      <?php echo e(number_format($orders->paid_credit ?? 0)); ?>

                    </td>
                    <!-- <td class="fw-semibold">
                      <?php echo e(number_format($orders->card_paid_amount ?? 0)); ?>

                    </td>
                    <td class="fw-semibold">
                    <?php echo e($orders->card_ref_no ?? '-'); ?>

                    </td> -->
                    <!-- <td class="fw-semibold">
                      <?php echo e($orders->order_date); ?>

                    </td>
                    <td class="fw-semibold">
                      <?php echo e($orders->delivery_date); ?>

                    </td>
                    <td class="fw-semibold">
                      <?php echo e($orders->price_method); ?>

                    </td>
                    <td class="fw-semibold">
                      <?php echo e(number_format($orders->total)); ?>

                    </td>
                    <td class="fw-semibold">
                    <?php if($orders->order_status == "Pending") { ?>
                        <span class="badge bg-warning">Pending</span>
                    <?php } else if($orders->order_status == "Processed") { ?>
                        <span class="badge bg-info">Processed</span>
                    <?php }else if($orders->order_status == "Shipped") { ?>
                        <span class="badge bg-primary">Shipped</span>
                    <?php }else if($orders->order_status == "Delivered") { ?>
                        <span class="badge bg-success">Delivered</span>
                    <?php }else{ ?>
                        <span class="badge bg-danger">Canceled</span>
                    <?php } ?>
                    </td> -->
                    <td class="text-center">
                        <div class="btn-group">
                        <!-- <a href="<?php echo e(url('admin/edit-order/'.$orders->id.'')); ?>" ><button type="button" class="btn btn-sm btn-alt-primary js-bs-tooltip-enabled" data-bs-toggle="tooltip" aria-label="Edit" data-bs-original-title="Edit">
                            <i class="fa fa-pencil-alt"></i>
                          </button></a> -->
                          <a href="<?php echo e(url('view-invoice/' . $orders->unique_id. '?source=system')); ?>" target="_blank"><button type="button" class="btn btn-sm btn-alt-success js-bs-tooltip-enabled" data-bs-toggle="tooltip" aria-label="Download" data-bs-original-title="Download">
                            <i class="fa fa-download"></i></button></a>
                            <a href="<?php echo e(url('admin/cancel-order/' . $orders->id)); ?>" target="_blank"><button type="button" class="btn btn-sm btn-alt-danger js-bs-tooltip-enabled" data-bs-toggle="tooltip" aria-label="Delete" data-bs-original-title="Delete">
                            <i class="fa fa-trash"></i></button></a>
                            <!-- <a href="<?php echo e(url('admin/credit-update/' . $orders->id)); ?>" ><button type="button" class="btn btn-sm btn-alt-primary js-bs-tooltip-enabled" data-bs-toggle="tooltip" aria-label="Credit" data-bs-original-title="Credit">
                            <i class="fa-solid fa-credit-card"></i> -->
                          </button></a>
             
                        </div>
                      </td>
                  </tr>
                <?php } ?>
                </tbody>
                
              </table>
            </div>
          </div>
          <!-- END Your Block -->
        </div>
        <!-- END Page Content -->
</main>
<!-- END Main Container -->
<?php echo $__env->make('admin::layouts.footer', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH D:\Part Time Work\erp-resturant\Modules/Admin\resources/views/sales/all_orders.blade.php ENDPATH**/ ?>