37497-vm/api.php
Flatlogic Bot 65bff23a0b 1
2026-01-16 09:31:10 +00:00

24 lines
704 B
PHP

<?php
require_once 'db/config.php';
header('Content-Type: application/json');
$action = $_GET['action'] ?? '';
if ($action == 'get_departments') {
$division_id = $_GET['division_id'] ?? 0;
$stmt = db()->prepare("SELECT id, name FROM departments WHERE division_id = ? ORDER BY name");
$stmt->execute([$division_id]);
$departments = $stmt->fetchAll();
echo json_encode($departments);
exit;
}
if ($action == 'get_roles') {
$department_id = $_GET['department_id'] ?? 0;
$stmt = db()->prepare("SELECT id, name FROM roles WHERE department_id = ? ORDER BY name");
$stmt->execute([$department_id]);
$roles = $stmt->fetchAll();
echo json_encode($roles);
exit;
}