<?= $this->extend('layout/template') ?>

<?= $this->section('content') ?>

<div class="container-fluid">

    <div class="card shadow-sm">
        <div class="card-header bg-warning text-white">
            <h4 class="mb-0">
                <i class="fas fa-book"></i>
                Aturan Peminjaman
            </h4>
        </div>
        <div class="card-body">

            <?php if (session()->getFlashdata('success')) : ?>
                <div class="alert alert-success">
                    <i class="fas fa-check"></i>
                    <?= session()->getFlashdata('success') ?>
                </div>
            <?php endif; ?>

            <?php if (session()->getFlashdata('error')) : ?>
                <div class="alert alert-danger">
                    <i class="fas fa-times"></i>
                    <?= session()->getFlashdata('error') ?>
                </div>
            <?php endif; ?>

            <form action="<?= base_url('pengaturan/peminjaman') ?>" method="post">
                <?= csrf_field() ?>
                <input type="hidden" name="id" value="<?= esc($pengaturan['id'] ?? '') ?>">

                <div class="row">
                    <div class="col-md-4">
                        <div class="mb-3">
                            <label class="form-label">Lama Pinjam (Hari)</label>
                            <input type="number" name="lama_pinjam" class="form-control" value="<?= esc($pengaturan['lama_pinjam'] ?? 7) ?>" min="1" max="365" required>
                            <small class="text-muted">Maksimal hari anggota boleh meminjam buku</small>
                        </div>
                    </div>
                    <div class="col-md-4">
                        <div class="mb-3">
                            <label class="form-label">Maksimal Buku</label>
                            <input type="number" name="maksimal_buku" class="form-control" value="<?= esc($pengaturan['maksimal_buku'] ?? 3) ?>" min="1" max="100" required>
                            <small class="text-muted">Jumlah maksimal buku yang bisa dipinjam bersamaan</small>
                        </div>
                    </div>
                    <div class="col-md-4">
                        <div class="mb-3">
                            <label class="form-label">Denda Per Hari (Rp)</label>
                            <input type="number" name="denda_perhari" class="form-control" value="<?= esc($pengaturan['denda_perhari'] ?? 1000) ?>" min="0" required>
                            <small class="text-muted">Denda keterlambatan per hari dalam rupiah</small>
                        </div>
                    </div>
                </div>

                <hr>

                <button type="submit" class="btn btn-warning">
                    <i class="fas fa-save"></i> Simpan Aturan
                </button>

                <a href="<?= base_url('pengaturan') ?>" class="btn btn-secondary">
                    <i class="fas fa-arrow-left"></i> Kembali
                </a>
            </form>

        </div>
    </div>

</div>

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