<?php
session_start();
require_once 'includes/database.php';
require_once 'Classes/Timetable.php';

header('Content-Type: application/json');

if(!isset($_SESSION['username'])) {
    echo json_encode(['success' => false, 'message' => 'Unauthorized']);
    exit();
}

$timetable = new Timetable();
$periods = $timetable->getAllPeriods();

echo json_encode([
    'success' => true,
    'periods' => $periods
]);
