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

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

    <div class="card shadow-sm mb-3">
        <div class="card-header bg-primary text-white">
            <i class="fas fa-book-open me-1"></i>
            <b>Edit Mata Pelajaran</b>
            <div class="small opacity-75">Master Akademik</div>
        </div>

        <div class="card-body">

            <?php if (session()->getFlashdata('errors')): ?>
                <div class="alert alert-danger">
                    <ul class="mb-0">
                        <?php foreach (session('errors') as $err): ?>
                            <li><?= esc($err) ?></li>
                        <?php endforeach ?>
                    </ul>
                </div>
            <?php endif ?>

            <h6 class="text-primary mb-3">
                <i class="fas fa-info-circle me-1"></i> Informasi Mapel
            </h6>

            <div class="row">
                <div class="col-md-4 mb-3">
                    <label>Kode Mapel *</label>
                    <input type="text" class="form-control" value="<?= esc($subject['kode_mapel']) ?>" readonly>

                    <input type="hidden" name="kode_mapel" value="<?= esc($subject['kode_mapel']) ?>">

                </div>

                <div class="col-md-8 mb-3">
                    <label>Nama Mata Pelajaran *</label>
                    <input type="text" name="nama_mapel" class="form-control" value="<?= esc($subject['nama_mapel']) ?>"
                        required>
                </div>

                <div class="col-md-6 mb-3">
                    <label>Kelompok *</label>
                    <select name="kelompok" class="form-select" required>
                        <option value="Umum" <?= $subject['kelompok'] == 'Umum' ? 'selected' : '' ?>>Umum</option>
                        <option value="Agama" <?= $subject['kelompok'] == 'Agama' ? 'selected' : '' ?>>Agama</option>
                        <option value="Muatan Lokal" <?= $subject['kelompok'] == 'Muatan Lokal' ? 'selected' : '' ?>>Muatan
                            Lokal</option>
                    </select>
                </div>

                <div class="col-md-6 mb-3">
                    <label>Status</label>
                    <select name="is_active" class="form-select">
                        <option value="1" <?= $subject['is_active'] == 1 ? 'selected' : '' ?>>Aktif</option>
                        <option value="0" <?= $subject['is_active'] == 0 ? 'selected' : '' ?>>Non Aktif</option>
                    </select>
                </div>
            </div>

        </div>

        <div class="card-footer text-end">
            <a href="<?= site_url('master/subject') ?>" class="btn btn-secondary">
                <i class="fas fa-arrow-left me-1"></i> Kembali
            </a>
            <button type="submit" class="btn btn-primary">
                <i class="fas fa-save me-1"></i> Simpan Perubahan
            </button>
        </div>
    </div>

</form>

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