33 lines
996 B
PHP
33 lines
996 B
PHP
<?php
|
|
|
|
/**
|
|
* Shared data for the deadline modal form (used by index.php and detail.php).
|
|
* Populates $employees, $departments, $subjects. Safe to include more than once.
|
|
*/
|
|
if (!isset($pdo) || !$pdo) {
|
|
$pdo = DBHandlerSelect::getInstance()->getConnection();
|
|
}
|
|
|
|
if (!isset($employees)) {
|
|
$employees = $pdo->query("
|
|
SELECT e.id, e.first_name, e.last_name, e.department_id, dep.name AS department_name
|
|
FROM employees e
|
|
LEFT JOIN departments dep ON dep.id = e.department_id
|
|
WHERE e.status = 'active'
|
|
ORDER BY e.first_name, e.last_name
|
|
")->fetchAll(PDO::FETCH_ASSOC);
|
|
}
|
|
|
|
if (!isset($departments)) {
|
|
$departments = $pdo->query("
|
|
SELECT id, name, code, color
|
|
FROM departments
|
|
WHERE is_active = 1
|
|
ORDER BY sort_order ASC, name ASC
|
|
")->fetchAll(PDO::FETCH_ASSOC);
|
|
}
|
|
|
|
if (!isset($subjects)) {
|
|
$subjects = $pdo->query("SELECT id, name, color FROM scad_subjects ORDER BY name")->fetchAll(PDO::FETCH_ASSOC);
|
|
}
|