<?php
/** @var array $orders */
/** @var int   $offset */
/** @var int   $total */
?>

<div class="status-table-wrap">
  <table class="status-manage-table">
    <thead>
      <tr>
        <th class="status-check-cell"><input type="checkbox" id="checkAll" aria-label="Pilih semua transaksi pada halaman ini"></th>
        <th>No. Transaksi</th>
        <th>Tanggal</th>
        <th>Status</th>
        <th>Tampil di Status Board?</th>
      </tr>
    </thead>
    <tbody>
      <?php if (empty($orders)): ?>
        <tr><td colspan="5" class="status-empty">Tidak ada transaksi dengan status Diambil/Dikirim.</td></tr>
      <?php else: ?>
        <?php foreach ($orders as $o):
          $badgeClass = ((int) $o['status_angka'] === 5) ? 'status-dikirim' : 'status-diambil';
          $transactionId = htmlspecialchars($o['id_transaksi'], ENT_QUOTES, 'UTF-8');
        ?>
          <tr>
            <td class="status-check-cell">
              <input type="checkbox" name="selected[]" value="<?= (int) $o['id_invoice'] ?>" aria-label="Pilih <?= $transactionId ?>">
            </td>
            <td><strong><?= $transactionId ?></strong></td>
            <td><?= htmlspecialchars($o['tgl_trx'], ENT_QUOTES, 'UTF-8') ?></td>
            <td><span class="status-badge <?= $badgeClass ?>"><?= htmlspecialchars($o['status_label'], ENT_QUOTES, 'UTF-8') ?></span></td>
            <td>
              <?php if ($o['hide_status_board']): ?>
                <span class="status-visibility status-hidden">Disembunyikan</span>
              <?php else: ?>
                <span class="status-visibility status-visible">Ditampilkan</span>
              <?php endif; ?>
            </td>
          </tr>
        <?php endforeach; ?>
      <?php endif; ?>
    </tbody>
  </table>
</div>

<div class="status-pagination">
  <?= $this->ajax_pagination->create_links(); ?>
</div>
