<?= view('components/print_header', ['printTitle' => '재고 현황']) ?>
<section class="border-b border-gray-300 p-2 shrink-0 bg-control-panel">
  <div class="flex flex-wrap items-center justify-between gap-y-2">
    <span class="text-sm font-bold text-gray-700">재고 현황</span>
    <div class="flex items-center gap-2">
      <a href="<?= mgmt_url('bag-inventory/export') ?>" class="no-print border border-btn-excel-border text-btn-excel-text px-3 py-1 rounded-sm text-sm hover:bg-green-50 transition">엑셀저장</a>
      <button onclick="window.print()" class="no-print border border-btn-print-border text-gray-600 px-3 py-1 rounded-sm text-sm hover:bg-gray-50 transition">인쇄</button>
    </div>
  </div>
</section>
<div class="border border-gray-300 rounded-lg p-4 overflow-auto mt-2">
  <table class="w-full data-table">
    <thead>
      <tr>
        <th class="w-16 text-center">번호</th>
        <th class="text-center">봉투코드</th>
        <th class="text-left">봉투명</th>
        <th class="text-right">현재재고(낱장)</th>
        <th class="text-center">최종갱신</th>
      </tr>
    </thead>
    <tbody class="text-right">
      <?php foreach ($list as $row): ?>
      <tr>
        <td class="text-center"><?= esc($row->bi_idx) ?></td>
        <td class="text-center font-mono"><?= esc($row->bi_bag_code) ?></td>
        <td class="text-left pl-2"><?= esc($row->bi_bag_name) ?></td>
        <td class="font-bold"><?= number_format((int) $row->bi_qty) ?></td>
        <td class="text-center"><?= esc($row->bi_updated_at) ?></td>
      </tr>
      <?php endforeach; ?>
      <?php if (empty($list)): ?>
      <tr><td colspan="5" class="text-center text-gray-400 py-4">등록된 재고가 없습니다.</td></tr>
      <?php endif; ?>
    </tbody>
  </table>
</div>
<?php if (isset($pager)): ?><div class="mt-3"><?= $pager->links() ?></div><?php endif; ?>
