<?= $this->extend('layout/admin') ?>
<?= $this->section('content') ?>

<div class="row justify-content-center">
    <div class="col-md-8">

        <div class="card shadow-sm">
            <div class="card-header bg-warning text-dark">
                <i class="fas fa-edit mr-2"></i>
                <b>Edit Kelas</b>
            </div>

            <form action="<?= site_url('master/kelas/update/' . $kelas['id']) ?>" method="post">
                <?= csrf_field() ?>

                <div class="card-body">

                    <div class="form-row">
                        <div class="form-group col-md-6">
                            <label>Kode Kelas</label>
                            <input type="text" name="kode_kelas" class="form-control"
                                value="<?= esc($kelas['kode_kelas']) ?>" required>
                        </div>

                        <div class="form-group col-md-6">
                            <label>Nama Kelas</label>
                            <input type="text" name="nama_kelas" class="form-control"
                                value="<?= esc($kelas['nama_kelas']) ?>" required>
                        </div>
                    </div>

                    <div class="form-row">
                        <div class="form-group col-md-4">
                            <label>Jenjang</label>
                            <select name="jenjang" class="form-control">
                                <?php foreach (['SD', 'SMP', 'SMA'] as $j): ?>
                                    <option <?= $kelas['jenjang'] == $j ? 'selected' : '' ?>>
                                        <?= $j ?>
                                    </option>
                                <?php endforeach ?>
                            </select>
                        </div>

                        <div class="form-group col-md-4">
                            <label>Tingkat</label>
                            <input type="number" name="tingkat" class="form-control" value="<?= $kelas['tingkat'] ?>">
                        </div>

                        <div class="form-group col-md-4">
                            <label>Kapasitas</label>
                            <input type="number" name="kapasitas" class="form-control"
                                value="<?= $kelas['kapasitas'] ?>">
                        </div>
                    </div>

                    <div class="form-group">
                        <label>Program</label>
                        <select name="program" class="form-control">
                            <?php foreach (['Nasional', 'Cambridge', 'IB', 'Tahfidz'] as $p): ?>
                                <option <?= $kelas['program'] == $p ? 'selected' : '' ?>>
                                    <?= $p ?>
                                </option>
                            <?php endforeach ?>
                        </select>
                    </div>

                    <div class="form-group">
                        <label>Status</label>
                        <select name="status" class="form-control">
                            <option value="aktif" <?= $kelas['status'] == 'aktif' ? 'selected' : '' ?>>Aktif</option>
                            <option value="nonaktif" <?= $kelas['status'] == 'nonaktif' ? 'selected' : '' ?>>Nonaktif</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label>Tahun Ajaran</label>
                        <input type="text" name="tahun_ajaran" class="form-control"
                            value="<?= esc($kelas['tahun_ajaran']) ?>" readonly>
                    </div>

                </div>

                <div class="card-footer text-right">
                    <a href="<?= site_url('master/kelas') ?>" class="btn btn-secondary">
                        Kembali
                    </a>
                    <button class="btn btn-warning text-dark">
                        <i class="fas fa-save"></i> Update
                    </button>
                </div>

            </form>
        </div>

    </div>
</div>

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