<?php echo $__env->make('admin::layouts.header', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
<?php
use App\Models\CustomerDetails;
use App\Models\Products;
?>
<main id="main-container">
        <!-- Page Content -->
        <div class="content">
          <!-- Quick Overview -->
          <div class="row items-push">
           <div class="col-6 col-lg-3">
              <a class="block block-rounded block-link-shadow text-center h-100 mb-0" href="javascript:void(0)">
                <div class="block-content py-5">
                     <p class="fw-semibold fs-sm text-muted text-uppercase mb-0">
                    Total Customers
                  </p>
                  <div class="fs-3 fw-semibold mb-1"><?php echo e($total_customers); ?></div>
                 
                </div>
              </a>
            </div>
            <div class="col-6 col-lg-3">
              <a class="block block-rounded block-link-shadow text-center h-100 mb-0" href="javascript:void(0)">
                <div class="block-content py-5">
                     <p class="fw-semibold fs-sm text-muted text-uppercase mb-0">
                    New Customers
                  </p>
                  <div class="fs-3 fw-semibold mb-1"><?php echo e($new_customers); ?></div>
                 
                </div>
              </a>
            </div>
            <div class="col-6 col-lg-3">
              <a class="block block-rounded block-link-shadow text-center h-100 mb-0" href="javascript:void(0)">
                <div class="block-content py-5">
                     <p class="fw-semibold fs-sm text-muted text-uppercase mb-0">
                   Monthly Orders
                  </p>
                  <div class="fs-3 fw-semibold mb-1"><?php echo e($month_orders); ?></div>
                 
                </div>
              </a>
            </div>
            <div class="col-6 col-lg-3">
              <a class="block block-rounded block-link-shadow text-center h-100 mb-0" href="javascript:void(0)">
                <div class="block-content py-5">
                    <p class="fw-semibold fs-sm text-muted text-uppercase mb-0">
                    Today Orders
                  </p>
                  <div class="fs-3 fw-semibold mb-1"><?php echo e($today_orders); ?></div>
                  
                </div>
              </a>
            </div>
             <div class="col-6 col-lg-3">
              <a class="block block-rounded block-link-shadow text-center h-100 mb-0" href="javascript:void(0)">
                <div class="block-content py-5">
                     <p class="fw-semibold fs-sm text-muted text-uppercase mb-0">
                    Today Sells
                  </p>
                  <div class="fs-3 fw-semibold mb-1">$<?php echo e($today_sells); ?></div>
                 
                </div>
              </a>
            </div>
          </div>
          <!-- END Quick Overview -->

         
         <div class="row">
            <div class="col-xl-6">
              <!-- Top Products -->
              <div class="block block-rounded">
                <div class="block-header block-header-default">
                  <h3 class="block-title">Monthly Cash Flow</h3>
                  <div class="block-options">
                    <button type="button" class="btn-block-option" data-toggle="block-option" data-action="state_toggle" data-action-mode="demo">
                      <i class="si si-refresh"></i>
                    </button>
                  </div>
                </div>
                <div class="block-content">
                  
                </div>
              </div>
              <!-- END Top Products -->
            </div>
            <div class="col-xl-6">
              <!-- Latest Orders -->
              <div class="block block-rounded">
                <div class="block-header block-header-default">
                  <h3 class="block-title">New Orders</h3>
                  <div class="block-options">
                    <button type="button" class="btn-block-option" data-toggle="block-option" data-action="state_toggle" data-action-mode="demo">
                      <i class="si si-refresh"></i>
                    </button>
                  </div>
                </div>
                <div class="block-content">
                  <table class="table table-borderless table-striped table-vcenter fs-sm">
                    <tbody>
                      <?php foreach($new_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); ?>

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

                    </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>
                   
                  </tr>
                <?php } ?>
                    </tbody>
                  </table>
                </div>
              </div>
              <!-- END Latest Orders -->
            </div>
          </div>
          
          <!-- Top Products and Latest Orders -->
          <div class="row">
            <div class="col-xl-6">
              <!-- Top Products -->
              <div class="block block-rounded">
                <div class="block-header block-header-default">
                  <h3 class="block-title">Best Selling Items</h3>
                  <div class="block-options">
                    <button type="button" class="btn-block-option" data-toggle="block-option" data-action="state_toggle" data-action-mode="demo">
                      <i class="si si-refresh"></i>
                    </button>
                  </div>
                </div>
                <div class="block-content">
                  <table class="table table-borderless table-striped table-vcenter fs-sm">
                    <tbody> 
                    <?php foreach($most_selling_products as $most_selling_product) {
                    $product_name = Products::withTrashed()->where('id', $most_selling_product->product)->value('product_name');
                    $product_code = Products::withTrashed()->where('id', $most_selling_product->product)->value('product_code');
                    ?>
                    <tr>
                    <td class="fw-semibold">
                      <?php echo e($product_name); ?>

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

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

                    </td>
                    </tr>
                    <?php } ?>
                    </tbody>
                  </table>
                </div>
              </div>
              <!-- END Top Products -->
            </div>
            <div class="col-xl-6">
              <!-- Latest Orders -->
              <div class="block block-rounded">
                <div class="block-header block-header-default">
                  <h3 class="block-title">Out of Stock Alert</h3>
                  <div class="block-options">
                    <button type="button" class="btn-block-option" data-toggle="block-option" data-action="state_toggle" data-action-mode="demo">
                      <i class="si si-refresh"></i>
                    </button>
                  </div>
                </div>
                <div class="block-content">
                  <table class="table table-borderless table-striped table-vcenter fs-sm">
                    <tbody> 
                    <?php foreach($low_stock_products as $low_stock_product) {
                    $product_name = Products::withTrashed()->where('id', $low_stock_product->product)->value('product_name');
                    $product_code = Products::withTrashed()->where('id', $low_stock_product->product)->value('product_code');
                    ?>
                    <tr>
                    <td class="fw-semibold">
                      <?php echo e($product_name); ?>

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

                    </td>
                    <td class="fw-semibold">
                    <?php if($low_stock_product->total_quantity == 0){ ?>
                       Out of Stock 
                    <?php }else{ ?>
                         <?php echo e($low_stock_product->total_quantity); ?>

                    <?php } ?>
                     
                    </td>
                    </tr>
                    <?php } ?>
                    </tbody>
                  </table>
                </div>
              </div>
              <!-- END Latest Orders -->
            </div>
          </div>
          <!-- END Top Products and Latest Orders -->
        </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\shoes\Modules/Admin\resources/views/dashboard/index.blade.php ENDPATH**/ ?>