<?php
header("Content-Type: application/json");
require("../../includes/config.php");

try {
    // Get unique section names for the current academic year
    $stmt = $pdo->prepare("SELECT DISTINCT section_name FROM enrollments WHERE academic_year_id = :year_id AND section_name != '' ORDER BY section_name ASC");
    $stmt->execute([':year_id' => APP_YEAR_ID]);
    $sections = $stmt->fetchAll(PDO::FETCH_COLUMN);

    echo json_encode($sections);
} catch (PDOException $e) {
    echo json_encode([]);
}?>