diff --git a/code/planning.php b/code/planning.php new file mode 100644 index 0000000000000000000000000000000000000000..4d1f897d7ff6d6585bb456a0f2477adc54db7bcc --- /dev/null +++ b/code/planning.php @@ -0,0 +1,92 @@ +<?php +ini_set('display_errors', 1); +ini_set('display_startup_errors', 1); +error_reporting(E_ALL); + +include 'config.php'; +session_start(); + +if (!isset($_SESSION['user'])) { + header('Location: login.php'); + exit; +} +$user = $_SESSION['user']; +// Récupérer toutes les sessions, y compris celles avant aujourd'hui +$stmt = $conn->prepare(" + SELECT subject, start_time, end_time + FROM Session + ORDER BY start_time ASC +"); +$stmt->execute(); +$result = $stmt->get_result(); + +$sessions = []; +while ($row = $result->fetch_assoc()) { + $day = date('Y-m-d', strtotime($row['start_time'])); // Date exacte + $sessions[$day][] = [ + 'subject' => $row['subject'], + 'start_time' => $row['start_time'], + 'end_time' => $row['end_time'] + ]; +} + +$stmt->close(); + +// Utiliser DateTime pour calculer le début de la semaine +$currentDate = new DateTime(); +$startOfWeek = clone $currentDate; +$startOfWeek->modify('monday this week'); // Trouver le lundi de cette semaine + +?> +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>Weekly Schedule</title> + <link rel="stylesheet" href="style.css"> +</head> +<body> + <?php include 'sidebar.php'; ?> + + <div class="main-content"> + <div class="planning-page"> + <h1>Programme hebdomadaire</h1> + <table> + <thead> + <tr> + <th>Date</th> + <th>Sessions</th> + </tr> + </thead> + <tbody> + <?php + // Afficher les dates de la semaine, de lundi à dimanche + for ($i = 0; $i < 7; $i++) { + $currentDay = clone $startOfWeek; + $currentDay->modify("+$i day"); // Ajouter les jours de la semaine + $date = $currentDay->format('Y-m-d'); // Formater la date au format Y-m-d + echo "<tr>"; + echo "<td>" . $date . "</td>"; // Afficher la date + echo "<td>"; + // Afficher les sessions pour ce jour + if (isset($sessions[$date])) { + foreach ($sessions[$date] as $session) { + echo "<span>"; + echo htmlspecialchars($session['subject']) . "<br>"; + echo date('H:i', strtotime($session['start_time'])) . " - " . date('H:i', strtotime($session['end_time'])); + echo "</span><br>"; + } + } else { + echo "<span>Pas de sessions</span>"; + } + echo "</td>"; + echo "</tr>"; + } + ?> + </tbody> + </table> + </div> + </div> +</body> +</html>