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

$response = ['classes' => [], 'years' => []];

try {
    // Get all active classes
    $classStmt = $pdo->query("SELECT id, class_name FROM classes ORDER BY class_name ASC");
    $response['classes'] = $classStmt->fetchAll(PDO::FETCH_ASSOC);

    // Get all academic years
    $yearStmt = $pdo->query("SELECT id, year_name, is_current FROM academic_years ORDER BY year_name DESC");
    $response['years'] = $yearStmt->fetchAll(PDO::FETCH_ASSOC);

} catch (PDOException $e) {
    http_response_code(500);
}

echo json_encode($response);