<!DOCTYPE html>
<html>
<head>
    <title>Daftar Barang ATK</title>
    <link rel="stylesheet" href="<?= base_url('assets/css/bootstrap.min.css'); ?>">
</head>
<body>
<div class="container mt-4">
    <h2>Daftar Barang ATK</h2>
    <table class="table table-bordered">
        <thead>
            <tr>
                <th>Nama Barang</th>
                <th>Stok</th>
                <th>Kategori</th>
                <th>Produk</th>
                <th>Aksi</th>
            </tr>
        </thead>
        <tbody>
            <?php foreach ($barang as $b): ?>
            <tr>
                <td><?= $b->nama_barang; ?></td>
                <td><?= $b->stok; ?></td>
                <td><?= $b->kategori; ?></td>
                <td><?= $b->produk; ?></td>
                <td>
                    <form action="<?= site_url('Admin/ATK/ATK_cart_controller/tambah_keranjang'); ?>" method="post" class="d-flex align-items-center">
                    <input type="hidden" name="nama_barang" value="<?= $b->nama_barang; ?>">
                    <input type="hidden" name="kategori"    value="<?= $b->kategori; ?>">
                    <input type="hidden" name="produk_id"   value="<?= $b->produk_id; ?>"><!-- pastikan ini ID produk -->
                    <input type="hidden" name="divisi_id"   value="<?= $divisi_id; ?>"><!-- pastikan variabel ini tersedia -->

                    <input type="number" name="jumlah" min="1" value="1" class="form-control me-2" style="width: 80px;">
                    <button type="submit" class="btn btn-primary btn-sm">Masukkan Keranjang</button>
                </form>

                <a href="<?= site_url('views/Admin/ATK/ATK_cart_controller/cart_view'); ?>" class="btn btn-success">Lihat Keranjang</a>

                </td>
            </tr>
            <?php endforeach; ?>
        </tbody>
    </table>

    <a href="<?= site_url('Admin/ATK/cart_view'); ?>" class="btn btn-success">Lihat Keranjang</a>
</div>
</body>
</html>
