<?php 
include 'koneksi.php';
cek_akses(['Guru']);

$jadwal = mysqli_query($conn, "SELECT s.*, u.full_name as supervisor, c.name as class_name 
    FROM supervisions s 
    JOIN users u ON s.supervisor_id=u.id 
    JOIN classes c ON s.class_id=c.id 
    WHERE s.teacher_id='{$_SESSION['user_id']}' 
    ORDER BY s.schedule_date DESC");
?>
<!DOCTYPE html>
<html>
<head><title>Jadwal Supervisi Saya</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/admin-lte@3.2/dist/css/adminlte.min.css">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/theme-istiqlal-green.css">
</head>
<body class="hold-transition sidebar-mini">
<div class="wrapper">
    <?php include 'sidebar.php'; ?>
    <div class="content-wrapper">
        <div class="content-header"><div class="container-fluid"><h1>Jadwal Supervisi</h1></div></div>
        <div class="content">
            <div class="container-fluid">
                <div class="card">
                    <div class="card-header bg-info text-white">Jadwal Supervisi Anda</div>
                    <div class="card-body">
                        <table class="table table-bordered">
                            <thead class="thead-dark"><tr><th>Tanggal</th><th>Jam</th><th>Kelas</th><th>Supervisor</th><th>Status</th><th>Catatan</th></tr></thead>
                            <tbody>
                                <?php while($row = mysqli_fetch_assoc($jadwal)): ?>
                                <tr>
                                    <td><?= date('d-m-Y', strtotime($row['schedule_date'])) ?></td>
                                    <td><?= $row['schedule_time'] ?></td>
                                    <td><?= $row['class_name'] ?></td>
                                    <td><?= $row['supervisor'] ?></td>
                                    <td><span class="badge badge-<?= ($row['status']=='Scheduled')?'warning':'success' ?>"><?= $row['status'] ?></span></td>
                                    <td><?= $row['notes'] ?></td>
                                </tr>
                                <?php endwhile; ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>