<?= $this->session->flashdata('pesan'); ?>
<div class="card">
    <div class="card-header d-flex justify-content-between align-items-center w-100">
        <h3 class="card-title mb-1" style="margin-top: 5px;">Halaman Tambah Pelanggaran Santri</h3>
    </div>
    <div class="col-lg-6 mt-2 ml-2 mb-4">
        <form action="<?= base_url('pelanggaransantri/tambah_aksi') ?>" method="POST">
            <input type="hidden" id="id_santri" name="id_santri">
            <div class="form-group">
                <label>NIS</label>
                <input type="text" id="NIS" name="NIS" class="form-control" data-url="<?= base_url('pelanggaransantri/get_nis_autocomplete') ?>" value="<?= set_value('NIS') ?>" placeholder="Input NIS">
                <?= form_error('NIS', '<div class="text-small text-danger">', '</div>'); ?>
            </div>
            <div class="form-group">
                <label>Nama Santri</label>
                <input type="text" id="nama_santri" name="nama_santri" class="form-control" data-url="<?= base_url('pelanggaransantri/get_nis_autocomplete') ?>" value="<?= set_value('nama_santri') ?>" placeholder="Input Nama Santri" readonly>
                <?= form_error('nama_santri', '<div class="text-small text-danger">', '</div>'); ?>
            </div>
            <div class="form-group">
                <label>Kelas Diniah</label>
                <!-- Tampilkan ke user (teks kelas, misal: "Al-Wadhih Banat") -->
                <input type="text" id="kelas_diniyah_display" class="form-control" value="<?= set_value('kelas_diniyah_display') ?>" placeholder="Kelas Diniyah" readonly>
                <!-- Disimpan ke database (berupa angka: 1, 2, 3, dst) -->
                <input type="hidden" name="kelas_diniyah" id="kelas_diniyah" value="<?= set_value('kelas_diniyah') ?>">
                <?= form_error('kelas_diniyah', '<div class="text-small text-danger">', '</div>'); ?>
            </div>
            <div class="form-group">
                <label>Pelanggaran</label>
                <input type="text" name="pelanggaran" class="form-control" value="<?= set_value('pelanggaran') ?>" placeholder="Input Pelanggaran">
                <?= form_error('pelanggaran', '<div class="text-small text-danger">', '</div>'); ?>
            </div>
            <div class="form-group">
                <label>Tanggal</label>
                <input type="text" id="tanggal" name="tanggal" class="form-control" value="<?= set_value('tanggal') ?>" placeholder="Input Tanggal">
                <?= form_error('tanggal', '<div class="text-small text-danger">', '</div>'); ?>
            </div>
            <div class="form-group">
                <label>Sanksi</label>
                <input type="text" name="sanksi" class="form-control" value="<?= set_value('sanksi') ?>" placeholder="Input Sanksi">
                <?= form_error('sanksi', '<div class="text-small text-danger">', '</div>'); ?>
            </div>
            <div class="form-group">
                <label>Keterangan</label>
                <select name="keterangan" class="form-control">
                    <option value="">-- Pilih Keterangan --</option>
                    <option value="Sudah Disanksi" <?= set_select('keterangan', 'Sudah Disanksi') ?>>Sudah Disanksi</option>
                    <option value="Belum Disanksi" <?= set_select('keterangan', 'Belum Disanksi') ?>>Belum Disanksi</option>
                </select>
                <?= form_error('keterangan', '<div class="text-small text-danger">', '</div>'); ?>
            </div>
            <a href="<?= base_url('pelanggaransantri') ?>" class="btn btn-danger btn-sm">
                <i class="fas fa-solid fa-angle-left"></i> Kembali
            </a>
            <button type="submit" class="btn btn-primary btn-sm"><i class="fas fa-save"></i> Simpan </button>
        </form>
    </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
<script>
    flatpickr("#tanggal", {
        dateFormat: "d/m/Y" // Menampilkan dalam format dd/mm/yyyy
    });
</script>