<?php echo $__env->make('admin::layouts.header', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
<?php
use App\Models\AdminDetails;
use App\Models\Orders;
use App\Models\OrderProducts;
?>
<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">Daily Updates</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">Report</li>
                  <li class="breadcrumb-item active" aria-current="page">Daily Updates</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">Daily Updates</h3>
            </div>
            <div class="block-content">
            <?php if(Session::has('success')): ?> <div class="alert alert-success mt-2 mb-2"><?php echo e(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 class="table table-bordered table-striped table-vcenter js-dataTable-buttons">
                <thead>
                  <tr>
                  <th>Customer ID</th>
                  <th>Customer Name</th>
                  <th>Email</th>
                  <th>Phone</th>
                  <th>Address</th>
                    <th>Sells Count</th>
                     <th>Amount</th>
                      <th>Item Count</th>
                  </tr>
                </thead>
                <tbody>
                <?php foreach($customers as $customer) {
                    $orders = Orders::where('customer', $customer->id)->get();
                    $amount = 0;
                    $order_products_count = 0;
                    foreach($orders as $order){
                        $amount = $amount + $order->total;
                        $order_products = OrderProducts::where('order_id', $order->id)->get();
                        foreach($order_products as $order_product){
                            $order_products_count = $order_products_count + $order_product->quantity;
                        }
                    }
                ?>
                  <tr>
                      <td class="fw-semibold">
                      <?php echo e($customer->id); ?>

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

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

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

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

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

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

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

                    </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 /var/www/erpadmin_ori_usr/data/www/erpadmin.orionux.xyz/Modules/Admin/resources/views/report/daily_updates.blade.php ENDPATH**/ ?>