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

<div class="row mb-4">
  <!-- ✅ Total SMS -->
  <div class="col-md-3">
    <div class="card border shadow-sm">
      <div class="card-body text-center p-3">
        <i class="fas fa-envelope fa-2x text-primary"></i>
        <h6 class="card-title mt-2 text-muted">Total SMS</h6>
        <p class="card-text fw-bold h5"><?php echo e($total); ?></p>
      </div>
    </div>
  </div>

  <!-- ✅ Successful SMS -->
  <div class="col-md-3">
    <div class="card border shadow-sm">
      <div class="card-body text-center p-3">
        <i class="fas fa-check-circle fa-2x text-success"></i>
        <h6 class="card-title mt-2 text-muted">Successful SMS</h6>
        <p class="card-text fw-bold h5"><?php echo e($successful); ?></p>
      </div>
    </div>
  </div>

  <!-- ✅ Failed SMS -->
  <div class="col-md-3">
    <div class="card border shadow-sm">
      <div class="card-body text-center p-3">
        <i class="fas fa-times-circle fa-2x text-danger"></i>
        <h6 class="card-title mt-2 text-muted">Failed SMS</h6>
        <p class="card-text fw-bold h5"><?php echo e($failed); ?></p>
      </div>
    </div>
  </div>

  <!-- ✅ SMS Usage -->
  <div class="col-md-3">
    <div class="card border shadow-sm">
      <div class="card-body text-center p-3">
        <i class="fas fa-chart-line fa-2x text-info"></i>
        <h6 class="card-title mt-2 text-muted">Usage Rate</h6>
        <p class="card-text fw-bold h5"><?php echo e($usage); ?>%</p>
      </div>
    </div>
  </div>
</div>


<div class="card mb-3">
  <div class="card-body pt-0">
    <div class="col-lg-4 pt-3 pt-lg-0">
      <div class="d-flex flex-between-center mb-3">
        <div class="d-flex align-items-center">
          <div class="icon-item icon-item-sm bg-soft-primary shadow-none me-2 bg-soft-success"><span class="fas fa-calendar-week text-success"></span></div>
          <h6 class="mb-0">Search Per Date</h6>
        </div>
      </div>
      <div class="d-flex">
        <div class="d-flex">
          <form class="form-material" method="POST" action="<?php echo e(url('sms')); ?>">
            <?php echo csrf_field(); ?>
            <br>
            <input type="date" value="<?php echo e(date('Y-m-d')); ?>" required class="form-control" name="start_date">
            <br>
            <input type="date" value="<?php echo e(date('Y-m-d')); ?>" required class="form-control" name="end_date">
            <br>
            <button type="submit" class="btn btn-primary btn-sm" aria-placeholder="Search"><i class="fas fa-search"></i>Submit</button>
          </form>
        </div>
      </div>
    </div>
  </div>
</div>
<div class="card mb-3">
  <div class="card-header">
    <div class="row flex-between-end">
      <div class="col-auto align-self-center">
        <form class="form-material" method="POST" action="<?php echo e(url ('/searchSms')); ?>">
          <?php echo csrf_field(); ?>
          <input type="text" required class="form-control" placeholder="Search by Payment ID" name="search" id="search">
          <br>
          <button type="submit" class="btn btn-primary btn-sm"><i class="fas fa-search"></i> Advanced Search</button>
        </form>
      </div>

      <!-- ✅ Show "Resend Failed SMS" Button Only for Admins (Role 3) -->
      <?php if(Auth::user()->role == 3): ?>
      <div class="col-auto">
        <a href="<?php echo e(route('admin.resend.failed.sms')); ?>" class="btn btn-danger btn-sm">
          <i class="fas fa-sync"></i> Resend Failed SMS
        </a>
      </div>
      <?php endif; ?>
    </div>
  </div>
  <div class="card-body pt-0">
    &nbsp;
    <br>
    <br>
    <h5 class="mb-0" data-anchor="data-anchor">List of all SMS Records</h5>
    <!-- Update the count and total based on your SMS model -->
    <p>Displaying <?php echo e($smsRecords->count()); ?> of <?php echo e($total); ?> SMS Records</p>
    <small>If you can't find the SMS record you are looking for, please use the advanced search option.</small>
    <!-- The table to display SMS records -->
    <div class="dt-responsive table-sm table-responsive">
      <small>
        <table id="order-table" class="table table-sm text-sm table-striped table-bordered nowrap">
          <thead class="bg-200 text-900">
            <tr>
              <th>#</th> <!-- ✅ New Column for Row Numbers -->
              <th>Action</th>
              <th>Destination Number</th>
              <th>Payment ID</th>
              <th>Policy #</th>
              <th>Date Sent</th>
            </tr>
          </thead>
          <tbody>
            <?php $__currentLoopData = $smsRecords; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $index => $sms): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <tr>
              <td><?php echo e($index + 1); ?></td> <!-- ✅ Display Row Number -->
              <td><a class="btn-primary btn-sm" href="<?php echo e(url('/sms/' . $sms->id)); ?>">View</a></td>
              <td><?php echo e($sms->destination_number); ?> - <?php if($sms->status == 1): ?>
                <span class="badge bg-success">Sent</span>
                <?php else: ?>
                <span class="badge bg-danger">Failed</span>
                <?php endif; ?>
              </td>
              <td><?php echo e($sms->payment_id); ?></td>
              <td><?php echo e($sms->member->national_id); ?></td>
              <td><?php echo e($sms->created_at->format('d-M-Y H:i:s')); ?></td>
            </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
          </tbody>
        </table>

      </small>
    </div>
  </div>
</div>

<script>
  // Your delete script remains unchanged
</script>

<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.admin', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\WORK-STATION\MBBS\Insurance-Version Controls\03-01-2026\resources\views/admin/sms.blade.php ENDPATH**/ ?>