<?php
/**
 * Archivo AJAX para obtener categorías por división
 * Turpial Airlines, C.A.
 */

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

require_once '../includes/functions.php';
require_once '../includes/Division.php';

if (!isset($_GET['division_id']) || !is_numeric($_GET['division_id'])) {
    echo json_encode([]);
    exit;
}

$division_id = (int)$_GET['division_id'];

try {
    $category = new Category();
    $categories = $category->getByDivision($division_id, true);
    echo json_encode($categories);
} catch (Exception $e) {
    echo json_encode([]);
}

?>