<?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\ManagerDetails;
use App\Models\CashierDetails;;
use App\Models\User;
use App\Models\CustomerDetails;
use App\Models\ShiftCashFlow;
use App\Models\Waiters;
use App\Models\Riders;
?>
<style>
  .offcanvas.offcanvas-end {
    width: 500px;

}
</style>
<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">Shift Reports</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">Shift Reports</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">Shift Reports</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; ?>

            <form method="GET" action="<?php echo e(url('admin/shift-report')); ?>" class=" mb-5">
              <div class="row mt-4 mb-4">
                <?php
                    $defaultStart = \Carbon\Carbon::now()->startOfDay()->format('Y-m-d\TH:i');
                ?>
                  <div class="col-md-3 mb-3">
                      <label class="form-label">Start Date</label>
                      <input type="datetime-local" class="form-control" name="start_date" value="<?php echo e(request('start_date', $defaultStart)); ?>" >
                      <?php if($errors->has('start_date')): ?> <div class="alert alert-danger mt-2"><?php echo e($errors->first('start_date')); ?></div> <?php endif; ?>
                  </div>
                  <div class="col-md-3 mb-3">
                      <label class="form-label">End Date</label>
                      <input type="datetime-local" class="form-control" name="end_date" value="<?php echo e(request('end_date', $defaultStart)); ?>" >
                      <?php if($errors->has('end_date')): ?> <div class="alert alert-danger mt-2"><?php echo e($errors->first('end_date')); ?></div> <?php endif; ?>
                  </div>
                  <div class="col-md-3 mb-3">
                      <label class="form-label">Cashier</label>
                      <select class="js-select2 form-select" name="cashier" style="width: 100%;" data-placeholder="Select a cashier..">
                          <option value="all">All</option>
                          <?php $__currentLoopData = $cashiers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $cashier): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                              <option value="<?php echo e($cashier->user_id); ?>" <?php echo e(request('cashier') == $cashier->user_id ? 'selected' : ''); ?>>
                                  <?php echo e($cashier->name); ?>

                              </option>
                          <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                      </select>
                      <?php if($errors->has('cashier')): ?> <div class="alert alert-danger mt-2"><?php echo e($errors->first('cashier')); ?></div> <?php endif; ?>
                  </div>
                 
              </div>
              <button type="submit" class="btn btn-primary">Filter</button>
              <a href="<?php echo e(url('admin/sales-report')); ?>"><button type="button" class="btn btn-success">Clear</button></a>
          </form>
            <table  id="example" class="custom-datatable display  nowrap" style="width:100%">
                <thead>
                  <tr>
                    <th>No</th>
                    <th>Date</th>
                    <th>Time</th>
                    <th>Shift ID</th>
                    <th>Cashier</th>
                    <th>Close Date</th>
                    <th>Close Time</th>
                    <th>Status</th>
                    <th>Actions</th>
                  </tr>
                </thead>
 <?php
    $no = 1;
  ?>
<tbody>
<?php foreach($shifts as $shift) {

  $cashier_role=User::withTrashed()->where('id', $shift->user_id)->value('user_role');
  $cashier_name = '-';
  if($cashier_role == 1){
      $cashier_name=AdminDetails::withTrashed()->where('user_id', $shift->user_id)->value('name');
  }
  if($cashier_role == 3){
      $cashier_name=ManagerDetails::withTrashed()->where('user_id', $shift->user_id)->value('name');
  }
  if($cashier_role == 4){
      $cashier_name=CashierDetails::withTrashed()->where('user_id', $shift->user_id)->value('name');
  }
  

?>
<tr>
    <td class="fw-semibold"><?php echo e($no); ?></td>
    <td class="fw-semibold"><?php echo e(\Carbon\Carbon::parse($shift->date_time)->format('Y-m-d')); ?></td>
    <td class="fw-semibold"><?php echo e(\Carbon\Carbon::parse($shift->date_time)->format('H:i')); ?></td>
    <td class="fw-semibold">SHFT-000<?php echo e($shift->id); ?></td>
    <td class="fw-semibold"><?php echo e($cashier_name); ?></td>
   <td class="fw-semibold">
    <?php echo e($shift->close_date_time ? \Carbon\Carbon::parse($shift->close_date_time)->format('Y-m-d') : '-'); ?>

  </td>
  <td class="fw-semibold">
      <?php echo e($shift->close_date_time ? \Carbon\Carbon::parse($shift->close_date_time)->format('H:i') : '-'); ?>

  </td>
  <td class="fw-semibold">
    <?php if($shift->close_date_time): ?>
        <span class="badge bg-danger">Closed</span>
    <?php else: ?>
        <span class="badge bg-success">Running</span>
    <?php endif; ?>
</td>
    <td class="text-center">
        <div class="btn-group">
         <button type="button" 
              class="btn btn-sm btn-alt-primary js-bs-tooltip-enabled view-bill-btn" 
              data-bs-toggle="offcanvas" 
              data-bs-target="#viewReport" 
              aria-controls="viewReport" 
              data-url="<?php echo e(url('admin/shift-bill/' . $shift->id . '?view=1')); ?>">
          <i class="fa fa-eye"></i>
      </button>


        </div>
    </td>
  </tr>
<?php  
$no =$no+1;
} ?>
</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(); ?>
<div class="offcanvas offcanvas-end bg-body-extra-light" tabindex="-1" id="viewReport" aria-labelledby="viewReportLabel">
    <div class="offcanvas-header bg-body-light">
        <h5 class="offcanvas-title" id="viewReportLabel">View Report</h5>
        <button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
    </div>
    <div class="offcanvas-body p-0">
        <iframe id="bill-frame" src="" width="100%" height="100%" frameborder="0" style="min-height: 80vh;"></iframe>
    </div>
</div>

<script>
document.addEventListener('DOMContentLoaded', function () {
    document.querySelectorAll('.view-bill-btn').forEach(function (button) {
        button.addEventListener('click', function () {
            const billUrl = this.getAttribute('data-url');
            document.getElementById('bill-frame').src = billUrl;
        });
    });
});

</script><?php /**PATH /home/u446954234/domains/orionerp.xyz/public_html/demo/Modules/Admin/resources/views/report/shift_report.blade.php ENDPATH**/ ?>