<?= $this->extend('layouts/main') ?>
<?= $this->section('content') ?>

<div class="container mt-4">
  <h4 class="mb-4 text-primary">Detail Produk Keluar: <?= esc($kode) ?></h4>

  <a href="<?= base_url('report/product_out') ?>" class="btn btn-secondary mb-3">
    <i class="fa fa-arrow-left"></i> Kembali
  </a>

  <div class="table-responsive rounded shadow-sm p-3 bg-white">
    <table class="table table-bordered table-hover table-sm">
      <thead class="table-light">
        <tr class="text-center align-middle">
          <th>Nama Barang</th>
          <th>Gudang</th>
          <th>Qty</th>
          <th>Barcode</th>
          <th>Tanggal</th>
          <th>Keterangan</th>
          <th>Dibuat Oleh</th>
        </tr>
      </thead>
      <tbody>
        <?php if (!empty($detail)): ?>
          <?php foreach ($detail as $row): ?>
            <tr>
              <td><?= esc($row['nama_item']) ?></td>
              <td><?= esc($row['nama_gudang']) ?></td>
              <td class="text-center"><?= esc($row['qty']) ?></td>
              <td><?= esc($row['barcode']) ?></td>
              <td><?= date('d-m-Y H:i', strtotime($row['tanggal_keluar'])) ?></td>
              <td><?= esc($row['keterangan'] ?? '-') ?></td>
              <td><?= esc($row['created_by'] ?? '-') ?></td>
            </tr>
          <?php endforeach ?>
        <?php else: ?>
          <tr>
            <td colspan="7" class="text-center text-muted">Data tidak ditemukan.</td>
          </tr>
        <?php endif ?>
      </tbody>
    </table>
  </div>
</div>

<?= $this->endSection() ?>
