<div class="row mb-3">
    <div class="col-lg-12">
        <h3 class="page-header"><strong>Input Data Jadwal</strong></h3>
    </div>
</div>

<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-primary">
            <div class="panel-heading">Input Data Jadwal Pelajaran</div>
            <div class="panel-body">
                <form method="post" action="./module/simpan.php?act=input_jadwal">
                    
                    <div class="form-group">
                        <label>Hari</label>
                        <select name="hari" class="form-control" required>
                            <option value="">-- Pilih Hari --</option>
                            <?php
                            $sqlHari = mysqli_query($koneksi, "SELECT * FROM hari ORDER BY idh ASC");
                            while($h = mysqli_fetch_array($sqlHari)){
                                echo "<option value='$h[idh]'>$h[hari]</option>";
                            }
                            ?>
                        </select>
                    </div>

                    <div class="form-group">
                        <label>Jam Mulai</label>
                        <input type="time" name="jam_mulai" class="form-control" required>
                    </div>

                    <div class="form-group">
                        <label>Jam Selesai</label>
                        <input type="time" name="jam_selesai" class="form-control" required>
                    </div>

                    <div class="form-group">
                        <label>Kelas</label>
                        <select name="kelas" class="form-control" required>
                            <option value="">-- Pilih Kelas --</option>
                            <?php
                            $sqlKelas = mysqli_query($koneksi, "SELECT * FROM kelas ORDER BY nama ASC");
                            while($k = mysqli_fetch_array($sqlKelas)){
                                // PENTING: Value harus IDK (angka), bukan nama kelas
                                echo "<option value='$k[idk]'>$k[nama]</option>";
                            }
                            ?>
                        </select>
                    </div>

                    <div class="form-group">
                        <label>Mata Pelajaran</label>
                        <select name="pelajaran" class="form-control" required>
                            <option value="">-- Pilih Mata Pelajaran --</option>
                            <?php
                            $sqlMapel = mysqli_query($koneksi, "SELECT * FROM mata_pelajaran ORDER BY nama_mp ASC");
                            while($m = mysqli_fetch_array($sqlMapel)){
                                // PENTING: Value harus IDM (angka)
                                echo "<option value='$m[idm]'>$m[nama_mp]</option>";
                            }
                            ?>
                        </select>
                    </div>

                    <div class="form-group">
                        <label>Guru Pengajar</label>
                        <select name="guru" class="form-control" required>
                            <option value="">-- Pilih Guru --</option>
                            <?php
                            $sqlGuru = mysqli_query($koneksi, "SELECT * FROM guru ORDER BY nama ASC");
                            while($g = mysqli_fetch_array($sqlGuru)){
                                // PENTING: Value harus IDG (angka)
                                echo "<option value='$g[idg]'>$g[nama]</option>";
                            }
                            ?>
                        </select>
                    </div>

                    <button type="submit" class="btn btn-success">Simpan</button>
                    <button type="reset" class="btn btn-danger">Batal</button>
                </form>
            </div>
        </div>
    </div>
</div>