24 lines
704 B
PHP
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;
|
|
} |