<?php $this->load->view('template/header'); ?>
<?php $this->load->view('template/sidebar'); ?>

<h3 class="mb-3">Form Penggantian Buku</h3>

<!-- CARD DATA BUKU YANG DIGANTI -->
<div class="card shadow-sm mb-4">
    <div class="card-header bg-danger text-white">
        <strong>Buku yang Harus Diganti</strong>
    </div>
    <div class="card-body">

        <table class="table table-bordered">
            <tr>
                <th width="200">Nama Anggota</th>
                <td><?= $detail->nama ?></td>
            </tr>
            <tr>
                <th>Buku Lama</th>
                <td><?= $detail->judul ?></td>
            </tr>
            <tr>
                <th>Jumlah</th>
                <td><?= $detail->jumlah ?></td>
            </tr>
            <tr>
                <th>Status</th>
                <td>
                    <span class="badge bg-danger">
                        <?= ucfirst($detail->status) ?>
                    </span>
                </td>
            </tr>
        </table>

    </div>
</div>

<!-- CARD INPUT BUKU PENGGANTI -->
<div class="card shadow-sm">
    <div class="card-header bg-success text-white">
        <strong>Input Buku Pengganti</strong>
    </div>
    <div class="card-body">

        <form method="post" action="<?= base_url('index.php/peminjaman/simpan_ganti')?>">

            <input type="hidden" name="id_detail" value="<?= $detail->id_detail ?>">

            <div class="mb-3">
                <label class="form-label">Judul Buku</label>
                <input name="judul" class="form-control" placeholder="Judul Buku" required>
            </div>

            <div class="mb-3">
                <label class="form-label">Kategori</label>
                <select name="kategori" class="form-select" required>
                    <?php foreach($kategori as $k){ ?>
                        <option value="<?= $k->id_kategori ?>">
                            <?= $k->nama_kategori ?>
                        </option>
                    <?php } ?>
                </select>
            </div>

            <div class="mb-3">
                <label class="form-label">Penulis</label>
                <input name="penulis" class="form-control" placeholder="Nama Penulis">
            </div>

            <div class="mb-3">
                <label class="form-label">Penerbit</label>
                <input name="penerbit" class="form-control" placeholder="Nama Penerbit">
            </div>

            <div class="mb-3">
                <label class="form-label">Tahun</label>
                <input name="tahun" type="number" class="form-control" placeholder="Tahun Terbit">
            </div>

            <div class="mt-3">
                <button class="btn btn-success">
                    Simpan Buku Pengganti
                </button>
                <a href="<?= base_url('index.php/peminjaman/monitoring') ?>" 
                   class="btn btn-secondary">
                    Kembali
                </a>
            </div>

        </form>

    </div>
</div>

<?php $this->load->view('template/footer'); ?>
