<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Joy Course</title>

    <!-- Bootstrap & AdminLTE CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/admin-lte/3.1.0/css/adminlte.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
</head>
<body class="hold-transition sidebar-mini">
    <!-- Wrapper -->
    <div class="wrapper">

        <!-- Navbar -->
        <?= view('layouts/navbar') ?>
        <!-- /.navbar -->

        <!-- bagian super admin -->
        <?php if (session()->get('role') === 'super admin'): ?>
        <?= view('layouts/sidebarsuperadmin') ?>
                <!-- Content Wrapper -->
                <div class="content-wrapper">
    <div class="content-header">
        <div class="container-fluid">
            <div class="row mb-4">
                <div class="col-sm-6">
                    <h1 class="mt-4">Edit Semua Jadwal Kelas</h1>
                </div>
            </div>
        </div>
    </div>

    <section class="content">
        <div class="container-fluid">
            <div class="row justify-content-center">
                <div class="col-md-8">
                    <div class="card shadow-sm">
                        <div class="card-header bg-info text-white">
                            <h4 class="mb-0">Form Edit Semua Jadwal Kelas</h4>
                        </div>
                        <div class="card-body">
                       

<!-- Form untuk edit semua jadwal -->
 <!-- Form untuk edit semua jadwal -->
 <form action="<?= base_url('jadwal/update_alll') ?>" method="post">
            <div class="table-responsive">
                <table class="table table-bordered table-striped">
                    <thead class="thead-dark">
                        <tr>
                            <th>Jam</th>
                            <th>Senin</th>
                          
                            <th>Selasa</th>
                        
                            <th>Rabu</th>
                       
                            <th>Kamis</th>
                        
                            <th>Jumat</th>
                     
                            <th>Sabtu</th>
                    
                        </tr>
                    </thead>
                    <tbody>
    <?php if (!empty($jadwal)) : ?>
        <?php foreach ($jadwal as $row) : ?>
            <tr>
            <td><?= date('H:i', strtotime($row['jam_mulai'])) ?> - <?= date('H:i', strtotime($row['jam_selesai'])) ?></td>
                <td>
                <select name="senin[<?= esc($row['id']) ?>]" class="form-control">
        <option value="FREE">Pilih Guru</option> <!-- Opsi default -->
        <?php foreach ($guru as $g): ?>
            <option value="<?= esc($g['nama_guru']) ?> (CALISTUNG)" <?= isset($row['senin']) && $row['senin'] == $g['nama_guru'] . ' (CALISTUNG)' ? 'selected' : '' ?>><?= esc($g['nama_guru']) ?> (CALISTUNG)</option>
            <option value="<?= esc($g['nama_guru']) ?> (PRIVAT)" <?= isset($row['senin']) && $row['senin'] == $g['nama_guru'] . ' (PRIVAT)' ? 'selected' : '' ?>><?= esc($g['nama_guru']) ?> (PRIVAT)</option>
            <option value="<?= esc($g['nama_guru']) ?> (SD)" <?= isset($row['senin']) && $row['senin'] == $g['nama_guru'] . ' (SD)' ? 'selected' : '' ?>><?= esc($g['nama_guru']) ?> (SD)</option>
            <option value="<?= esc($g['nama_guru']) ?> (B.ING)" <?= isset($row['senin']) && $row['senin'] == $g['nama_guru'] . ' (B.ING)' ? 'selected' : '' ?>><?= esc($g['nama_guru']) ?> (B.ING)</option>
            <option value="<?= esc($g['nama_guru']) ?> (SMP)" <?= isset($row['senin']) && $row['senin'] == $g['nama_guru'] . ' (SMP)' ? 'selected' : '' ?>><?= esc($g['nama_guru']) ?> (SMP)</option>
            <option value="<?= esc($g['nama_guru']) ?> (SMA)" <?= isset($row['senin']) && $row['senin'] == $g['nama_guru'] . ' (SMA)' ? 'selected' : '' ?>><?= esc($g['nama_guru']) ?> (SMA)</option>
        <?php endforeach; ?>
    </select>
                    <br>
                    <input type="text" name="keterangan1[<?= esc($row['id']) ?>]" value="<?= esc($row['keterangan1']) ?>" class="form-control">
                </td>
                <td>
    <select name="selasa[<?= esc($row['id']) ?>]" class="form-control">
        <option value="FREE">Pilih Guru</option> <!-- Opsi default -->
        <?php foreach ($guru as $g): ?>
            <option value="<?= esc($g['nama_guru']) ?> (CALISTUNG)" <?= isset($row['selasa']) && $row['selasa'] == $g['nama_guru'] . ' (CALISTUNG)' ? 'selected' : '' ?>><?= esc($g['nama_guru']) ?> (CALISTUNG)</option>
            <option value="<?= esc($g['nama_guru']) ?> (PRIVAT)" <?= isset($row['selasa']) && $row['selasa'] == $g['nama_guru'] . ' (PRIVAT)' ? 'selected' : '' ?>><?= esc($g['nama_guru']) ?> (PRIVAT)</option>
            <option value="<?= esc($g['nama_guru']) ?> (SD)" <?= isset($row['selasa']) && $row['selasa'] == $g['nama_guru'] . ' (SD)' ? 'selected' : '' ?>><?= esc($g['nama_guru']) ?> (SD)</option>
            <option value="<?= esc($g['nama_guru']) ?> (B.ING)" <?= isset($row['selasa']) && $row['selasa'] == $g['nama_guru'] . ' (B.ING)' ? 'selected' : '' ?>><?= esc($g['nama_guru']) ?> (B.ING)</option>
            <option value="<?= esc($g['nama_guru']) ?> (SMP)" <?= isset($row['selasa']) && $row['selasa'] == $g['nama_guru'] . ' (SMP)' ? 'selected' : '' ?>><?= esc($g['nama_guru']) ?> (SMP)</option>
            <option value="<?= esc($g['nama_guru']) ?> (SMA)" <?= isset($row['selasa']) && $row['selasa'] == $g['nama_guru'] . ' (SMA)' ? 'selected' : '' ?>><?= esc($g['nama_guru']) ?> (SMA)</option>
        <?php endforeach; ?>
    </select>
    <br>
    <input type="text" name="keterangan2[<?= esc($row['id']) ?>]" value="<?= esc($row['keterangan2']) ?>" class="form-control">
</td>

<td>
    <select name="rabu[<?= esc($row['id']) ?>]" class="form-control">
        <option value="FREE">Pilih Guru</option> <!-- Opsi default -->
        <?php foreach ($guru as $g): ?>
            <option value="<?= esc($g['nama_guru']) ?> (CALISTUNG)" <?= isset($row['rabu']) && $row['rabu'] == $g['nama_guru'] . ' (CALISTUNG)' ? 'selected' : '' ?>><?= esc($g['nama_guru']) ?> (CALISTUNG)</option>
            <option value="<?= esc($g['nama_guru']) ?> (PRIVAT)" <?= isset($row['rabu']) && $row['rabu'] == $g['nama_guru'] . ' (PRIVAT)' ? 'selected' : '' ?>><?= esc($g['nama_guru']) ?> (PRIVAT)</option>
            <option value="<?= esc($g['nama_guru']) ?> (SD)" <?= isset($row['rabu']) && $row['rabu'] == $g['nama_guru'] . ' (SD)' ? 'selected' : '' ?>><?= esc($g['nama_guru']) ?> (SD)</option>
            <option value="<?= esc($g['nama_guru']) ?> (B.ING)" <?= isset($row['rabu']) && $row['rabu'] == $g['nama_guru'] . ' (B.ING)' ? 'selected' : '' ?>><?= esc($g['nama_guru']) ?> (B.ING)</option>
            <option value="<?= esc($g['nama_guru']) ?> (SMP)" <?= isset($row['rabu']) && $row['rabu'] == $g['nama_guru'] . ' (SMP)' ? 'selected' : '' ?>><?= esc($g['nama_guru']) ?> (SMP)</option>
            <option value="<?= esc($g['nama_guru']) ?> (SMA)" <?= isset($row['rabu']) && $row['rabu'] == $g['nama_guru'] . ' (SMA)' ? 'selected' : '' ?>><?= esc($g['nama_guru']) ?> (SMA)</option>
        <?php endforeach; ?>
    </select>
    <br>
    <input type="text" name="keterangan3[<?= esc($row['id']) ?>]" value="<?= esc($row['keterangan3']) ?>" class="form-control">
</td>

<td>
    <select name="kamis[<?= esc($row['id']) ?>]" class="form-control">
        <option value="FREE">Pilih Guru</option> <!-- Opsi default -->
        <?php foreach ($guru as $g): ?>
            <option value="<?= esc($g['nama_guru']) ?> (CALISTUNG)" <?= isset($row['kamis']) && $row['kamis'] == $g['nama_guru'] . ' (CALISTUNG)' ? 'selected' : '' ?>><?= esc($g['nama_guru']) ?> (CALISTUNG)</option>
            <option value="<?= esc($g['nama_guru']) ?> (PRIVAT)" <?= isset($row['kamis']) && $row['kamis'] == $g['nama_guru'] . ' (PRIVAT)' ? 'selected' : '' ?>><?= esc($g['nama_guru']) ?> (PRIVAT)</option>
            <option value="<?= esc($g['nama_guru']) ?> (SD)" <?= isset($row['kamis']) && $row['kamis'] == $g['nama_guru'] . ' (SD)' ? 'selected' : '' ?>><?= esc($g['nama_guru']) ?> (SD)</option>
            <option value="<?= esc($g['nama_guru']) ?> (B.ING)" <?= isset($row['kamis']) && $row['kamis'] == $g['nama_guru'] . ' (B.ING)' ? 'selected' : '' ?>><?= esc($g['nama_guru']) ?> (B.ING)</option>
            <option value="<?= esc($g['nama_guru']) ?> (SMP)" <?= isset($row['kamis']) && $row['kamis'] == $g['nama_guru'] . ' (SMP)' ? 'selected' : '' ?>><?= esc($g['nama_guru']) ?> (SMP)</option>
            <option value="<?= esc($g['nama_guru']) ?> (SMA)" <?= isset($row['kamis']) && $row['kamis'] == $g['nama_guru'] . ' (SMA)' ? 'selected' : '' ?>><?= esc($g['nama_guru']) ?> (SMA)</option>
        <?php endforeach; ?>
    </select>
    <br>
    <input type="text" name="keterangan4[<?= esc($row['id']) ?>]" value="<?= esc($row['keterangan4']) ?>" class="form-control">
</td>

<td>
    <select name="jumat[<?= esc($row['id']) ?>]" class="form-control">
        <option value="FREE">Pilih Guru</option> <!-- Opsi default -->
        <?php foreach ($guru as $g): ?>
            <option value="<?= esc($g['nama_guru']) ?> (CALISTUNG)" <?= isset($row['jumat']) && $row['jumat'] == $g['nama_guru'] . ' (CALISTUNG)' ? 'selected' : '' ?>><?= esc($g['nama_guru']) ?> (CALISTUNG)</option>
            <option value="<?= esc($g['nama_guru']) ?> (PRIVAT)" <?= isset($row['jumat']) && $row['jumat'] == $g['nama_guru'] . ' (PRIVAT)' ? 'selected' : '' ?>><?= esc($g['nama_guru']) ?> (PRIVAT)</option>
            <option value="<?= esc($g['nama_guru']) ?> (SD)" <?= isset($row['jumat']) && $row['jumat'] == $g['nama_guru'] . ' (SD)' ? 'selected' : '' ?>><?= esc($g['nama_guru']) ?> (SD)</option>
            <option value="<?= esc($g['nama_guru']) ?> (B.ING)" <?= isset($row['jumat']) && $row['jumat'] == $g['nama_guru'] . ' (B.ING)' ? 'selected' : '' ?>><?= esc($g['nama_guru']) ?> (B.ING)</option>
            <option value="<?= esc($g['nama_guru']) ?> (SMP)" <?= isset($row['jumat']) && $row['jumat'] == $g['nama_guru'] . ' (SMP)' ? 'selected' : '' ?>><?= esc($g['nama_guru']) ?> (SMP)</option>
            <option value="<?= esc($g['nama_guru']) ?> (SMA)" <?= isset($row['jumat']) && $row['jumat'] == $g['nama_guru'] . ' (SMA)' ? 'selected' : '' ?>><?= esc($g['nama_guru']) ?> (SMA)</option>
        <?php endforeach; ?>
    </select>
    <br>
    <input type="text" name="keterangan5[<?= esc($row['id']) ?>]" value="<?= esc($row['keterangan5']) ?>" class="form-control">
</td>

<td>
    <select name="sabtu[<?= esc($row['id']) ?>]" class="form-control">
        <option value="FREE">Pilih Guru</option> <!-- Opsi default -->
        <?php foreach ($guru as $g): ?>
            <option value="<?= esc($g['nama_guru']) ?> (CALISTUNG)" <?= isset($row['sabtu']) && $row['sabtu'] == $g['nama_guru'] . ' (CALISTUNG)' ? 'selected' : '' ?>><?= esc($g['nama_guru']) ?> (CALISTUNG)</option>
            <option value="<?= esc($g['nama_guru']) ?> (PRIVAT)" <?= isset($row['sabtu']) && $row['sabtu'] == $g['nama_guru'] . ' (PRIVAT)' ? 'selected' : '' ?>><?= esc($g['nama_guru']) ?> (PRIVAT)</option>
            <option value="<?= esc($g['nama_guru']) ?> (SD)" <?= isset($row['sabtu']) && $row['sabtu'] == $g['nama_guru'] . ' (SD)' ? 'selected' : '' ?>><?= esc($g['nama_guru']) ?> (SD)</option>
            <option value="<?= esc($g['nama_guru']) ?> (B.ING)" <?= isset($row['sabtu']) && $row['sabtu'] == $g['nama_guru'] . ' (B.ING)' ? 'selected' : '' ?>><?= esc($g['nama_guru']) ?> (B.ING)</option>
            <option value="<?= esc($g['nama_guru']) ?> (SMP)" <?= isset($row['sabtu']) && $row['sabtu'] == $g['nama_guru'] . ' (SMP)' ? 'selected' : '' ?>><?= esc($g['nama_guru']) ?> (SMP)</option>
            <option value="<?= esc($g['nama_guru']) ?> (SMA)" <?= isset($row['sabtu']) && $row['sabtu'] == $g['nama_guru'] . ' (SMA)' ? 'selected' : '' ?>><?= esc($g['nama_guru']) ?> (SMA)</option>
        <?php endforeach; ?>
    </select>
    <br>
    <input type="text" name="keterangan6[<?= esc($row['id']) ?>]" value="<?= esc($row['keterangan6']) ?>" class="form-control">
</td>

            </tr>
        <?php endforeach; ?>
    <?php else : ?>
        <tr>
            <td colspan="12" class="text-center">Tidak ada jadwal tersedia.</td>
        </tr>
    <?php endif; ?>
</tbody>

                </table>
                <button type="submit" class="btn btn-primary">Simpan Semua Perubahan</button>
            </div>
        </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
</div>

        <!-- /.content-wrapper -->                   
    </div>
     <?php else: ?>
     <div class="alert alert-danger">
     <h4>Anda tidak memiliki akses ke halaman ini.</h4>
     </div>
    <?php endif; ?>
    <!-- Bootstrap & AdminLTE JS -->
    <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/admin-lte/3.1.0/js/adminlte.min.js"></script>
    <!-- jQuery -->
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.bundle.min.js"></script>


</body>
</html>
