<?php
header('Content-Type: application/json');
require("../../includes/config.php"); // Adjust path if needed

try {
    // Fetch all academic years from your table
    $stmt = $pdo->query("SELECT id, year_name, is_current FROM academic_years ORDER BY id DESC");
    $years = $stmt->fetchAll(PDO::FETCH_ASSOC);

    echo json_encode([
        'status' => 'success',
        'data' => $years
    ]);
} catch (PDOException $e) {
    echo json_encode([
        'status' => 'error', 
        'message' => $e->getMessage()
    ]);
}
?>