added depart,ments to employee and deadlines
This commit is contained in:
parent
5728afa788
commit
ac942dcdc8
@ -21,7 +21,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['ajax']) && $_POST['aj
|
|||||||
$employee_code = trim($_POST['employee_code'] ?? '');
|
$employee_code = trim($_POST['employee_code'] ?? '');
|
||||||
$first_name = trim($_POST['first_name'] ?? '');
|
$first_name = trim($_POST['first_name'] ?? '');
|
||||||
$last_name = trim($_POST['last_name'] ?? '');
|
$last_name = trim($_POST['last_name'] ?? '');
|
||||||
$department = trim($_POST['department'] ?? '');
|
$department_id = $_POST['department_id'] !== '' ? (int)$_POST['department_id'] : null;
|
||||||
$position = trim($_POST['position'] ?? '');
|
$position = trim($_POST['position'] ?? '');
|
||||||
$hire_date = trim($_POST['hire_date'] ?? '');
|
$hire_date = trim($_POST['hire_date'] ?? '');
|
||||||
$status = trim($_POST['status'] ?? 'active');
|
$status = trim($_POST['status'] ?? 'active');
|
||||||
@ -40,16 +40,16 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['ajax']) && $_POST['aj
|
|||||||
}
|
}
|
||||||
|
|
||||||
$sql = "INSERT INTO employees
|
$sql = "INSERT INTO employees
|
||||||
(auth_user_id, employee_code, first_name, last_name, department, position, hire_date, status, created_at, updated_at)
|
(auth_user_id, employee_code, first_name, last_name, department_id, position, hire_date, status, created_at, updated_at)
|
||||||
VALUES
|
VALUES
|
||||||
(:auth_user_id, :employee_code, :first_name, :last_name, :department, :position, :hire_date, :status, NOW(), NOW())";
|
(:auth_user_id, :employee_code, :first_name, :last_name, :department_id, :position, :hire_date, :status, NOW(), NOW())";
|
||||||
$stmt = $pdo->prepare($sql);
|
$stmt = $pdo->prepare($sql);
|
||||||
$stmt->execute([
|
$stmt->execute([
|
||||||
'auth_user_id' => $auth_user_id,
|
'auth_user_id' => $auth_user_id,
|
||||||
'employee_code' => $employee_code !== '' ? $employee_code : null,
|
'employee_code' => $employee_code !== '' ? $employee_code : null,
|
||||||
'first_name' => $first_name,
|
'first_name' => $first_name,
|
||||||
'last_name' => $last_name,
|
'last_name' => $last_name,
|
||||||
'department' => $department !== '' ? $department : null,
|
'department_id' => $department_id,
|
||||||
'position' => $position !== '' ? $position : null,
|
'position' => $position !== '' ? $position : null,
|
||||||
'hire_date' => $hire_date !== '' ? $hire_date : null,
|
'hire_date' => $hire_date !== '' ? $hire_date : null,
|
||||||
'status' => $status
|
'status' => $status
|
||||||
@ -65,7 +65,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['ajax']) && $_POST['aj
|
|||||||
$employee_code = trim($_POST['employee_code'] ?? '');
|
$employee_code = trim($_POST['employee_code'] ?? '');
|
||||||
$first_name = trim($_POST['first_name'] ?? '');
|
$first_name = trim($_POST['first_name'] ?? '');
|
||||||
$last_name = trim($_POST['last_name'] ?? '');
|
$last_name = trim($_POST['last_name'] ?? '');
|
||||||
$department = trim($_POST['department'] ?? '');
|
$department_id = $_POST['department_id'] !== '' ? (int)$_POST['department_id'] : null;
|
||||||
$position = trim($_POST['position'] ?? '');
|
$position = trim($_POST['position'] ?? '');
|
||||||
$hire_date = trim($_POST['hire_date'] ?? '');
|
$hire_date = trim($_POST['hire_date'] ?? '');
|
||||||
$status = trim($_POST['status'] ?? 'active');
|
$status = trim($_POST['status'] ?? 'active');
|
||||||
@ -93,7 +93,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['ajax']) && $_POST['aj
|
|||||||
employee_code = :employee_code,
|
employee_code = :employee_code,
|
||||||
first_name = :first_name,
|
first_name = :first_name,
|
||||||
last_name = :last_name,
|
last_name = :last_name,
|
||||||
department = :department,
|
department_id = :department_id,
|
||||||
position = :position,
|
position = :position,
|
||||||
hire_date = :hire_date,
|
hire_date = :hire_date,
|
||||||
status = :status,
|
status = :status,
|
||||||
@ -105,7 +105,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['ajax']) && $_POST['aj
|
|||||||
'employee_code' => $employee_code !== '' ? $employee_code : null,
|
'employee_code' => $employee_code !== '' ? $employee_code : null,
|
||||||
'first_name' => $first_name,
|
'first_name' => $first_name,
|
||||||
'last_name' => $last_name,
|
'last_name' => $last_name,
|
||||||
'department' => $department !== '' ? $department : null,
|
'department_id' => $department_id,
|
||||||
'position' => $position !== '' ? $position : null,
|
'position' => $position !== '' ? $position : null,
|
||||||
'hire_date' => $hire_date !== '' ? $hire_date : null,
|
'hire_date' => $hire_date !== '' ? $hire_date : null,
|
||||||
'status' => $status,
|
'status' => $status,
|
||||||
@ -193,9 +193,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['ajax']) && $_POST['aj
|
|||||||
// Employees list
|
// Employees list
|
||||||
$sql = "
|
$sql = "
|
||||||
SELECT e.*,
|
SELECT e.*,
|
||||||
|
d.name AS department_name,
|
||||||
|
d.color AS department_color,
|
||||||
au.email AS user_email,
|
au.email AS user_email,
|
||||||
CONCAT(COALESCE(au.first_name, ''), ' ', COALESCE(au.last_name, '')) AS user_fullname
|
CONCAT(COALESCE(au.first_name, ''), ' ', COALESCE(au.last_name, '')) AS user_fullname
|
||||||
FROM employees e
|
FROM employees e
|
||||||
|
LEFT JOIN departments d ON e.department_id = d.id
|
||||||
LEFT JOIN auth_users au ON e.auth_user_id = au.id
|
LEFT JOIN auth_users au ON e.auth_user_id = au.id
|
||||||
ORDER BY e.id DESC
|
ORDER BY e.id DESC
|
||||||
";
|
";
|
||||||
@ -219,6 +222,16 @@ $sqlUsers = "
|
|||||||
$stmtUsers = $pdo->query($sqlUsers);
|
$stmtUsers = $pdo->query($sqlUsers);
|
||||||
$users = $stmtUsers->fetchAll(PDO::FETCH_ASSOC);
|
$users = $stmtUsers->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
// Departments list for select
|
||||||
|
$sqlDepartments = "
|
||||||
|
SELECT id, name, code, color
|
||||||
|
FROM departments
|
||||||
|
WHERE is_active = 1
|
||||||
|
ORDER BY sort_order ASC, name ASC
|
||||||
|
";
|
||||||
|
$stmtDepartments = $pdo->query($sqlDepartments);
|
||||||
|
$departments = $stmtDepartments->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
// Skills list for JS
|
// Skills list for JS
|
||||||
$sqlSkills = "
|
$sqlSkills = "
|
||||||
SELECT s.id, s.name, pl.name as line_name, pl.line_number
|
SELECT s.id, s.name, pl.name as line_name, pl.line_number
|
||||||
@ -347,6 +360,15 @@ $allSkills = $stmtSkills->fetchAll(PDO::FETCH_ASSOC);
|
|||||||
background-color: #157347;
|
background-color: #157347;
|
||||||
transform: scale(1.02);
|
transform: scale(1.02);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.department-badge {
|
||||||
|
display: inline-block;
|
||||||
|
color: #fff;
|
||||||
|
padding: 0.25rem 0.6rem;
|
||||||
|
border-radius: 999px;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
@ -421,7 +443,15 @@ $allSkills = $stmtSkills->fetchAll(PDO::FETCH_ASSOC);
|
|||||||
<td><?= (int)$row['id'] ?></td>
|
<td><?= (int)$row['id'] ?></td>
|
||||||
<td><?= htmlspecialchars($row['employee_code'] ?? '') ?></td>
|
<td><?= htmlspecialchars($row['employee_code'] ?? '') ?></td>
|
||||||
<td><?= htmlspecialchars($fullName) ?></td>
|
<td><?= htmlspecialchars($fullName) ?></td>
|
||||||
<td><?= htmlspecialchars($row['department'] ?? '') ?></td>
|
<td>
|
||||||
|
<?php if (!empty($row['department_name'])): ?>
|
||||||
|
<span class="department-badge" style="background-color: <?= htmlspecialchars($row['department_color'] ?? '#6c757d', ENT_QUOTES) ?>;">
|
||||||
|
<?= htmlspecialchars($row['department_name']) ?>
|
||||||
|
</span>
|
||||||
|
<?php else: ?>
|
||||||
|
-
|
||||||
|
<?php endif; ?>
|
||||||
|
</td>
|
||||||
<td><?= htmlspecialchars($row['position'] ?? '') ?></td>
|
<td><?= htmlspecialchars($row['position'] ?? '') ?></td>
|
||||||
<td><?= $hireDate ?></td>
|
<td><?= $hireDate ?></td>
|
||||||
<td>
|
<td>
|
||||||
@ -437,7 +467,7 @@ $allSkills = $stmtSkills->fetchAll(PDO::FETCH_ASSOC);
|
|||||||
data-code="<?= htmlspecialchars($row['employee_code'] ?? '', ENT_QUOTES) ?>"
|
data-code="<?= htmlspecialchars($row['employee_code'] ?? '', ENT_QUOTES) ?>"
|
||||||
data-first_name="<?= htmlspecialchars($row['first_name'] ?? '', ENT_QUOTES) ?>"
|
data-first_name="<?= htmlspecialchars($row['first_name'] ?? '', ENT_QUOTES) ?>"
|
||||||
data-last_name="<?= htmlspecialchars($row['last_name'] ?? '', ENT_QUOTES) ?>"
|
data-last_name="<?= htmlspecialchars($row['last_name'] ?? '', ENT_QUOTES) ?>"
|
||||||
data-department="<?= htmlspecialchars($row['department'] ?? '', ENT_QUOTES) ?>"
|
data-department_id="<?= $row['department_id'] !== null ? (int)$row['department_id'] : '' ?>"
|
||||||
data-position="<?= htmlspecialchars($row['position'] ?? '', ENT_QUOTES) ?>"
|
data-position="<?= htmlspecialchars($row['position'] ?? '', ENT_QUOTES) ?>"
|
||||||
data-hire_date="<?= htmlspecialchars($row['hire_date'] ?? '', ENT_QUOTES) ?>"
|
data-hire_date="<?= htmlspecialchars($row['hire_date'] ?? '', ENT_QUOTES) ?>"
|
||||||
data-status="<?= htmlspecialchars($status, ENT_QUOTES) ?>"
|
data-status="<?= htmlspecialchars($status, ENT_QUOTES) ?>"
|
||||||
@ -477,7 +507,7 @@ $allSkills = $stmtSkills->fetchAll(PDO::FETCH_ASSOC);
|
|||||||
|
|
||||||
<!-- MODALE AGGIUNTA DIPENDENTE -->
|
<!-- MODALE AGGIUNTA DIPENDENTE -->
|
||||||
<div class="modal fade" id="addEmployeeModal" tabindex="-1">
|
<div class="modal fade" id="addEmployeeModal" tabindex="-1">
|
||||||
<div class="modal-dialog modal-dialog-centered">
|
<div class="modal-dialog modal-lg modal-dialog-centered">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header" style="background-color:#cfe3ff;">
|
<div class="modal-header" style="background-color:#cfe3ff;">
|
||||||
<h5 class="modal-title">Aggiungi Nuovo Dipendente</h5>
|
<h5 class="modal-title">Aggiungi Nuovo Dipendente</h5>
|
||||||
@ -505,7 +535,15 @@ $allSkills = $stmtSkills->fetchAll(PDO::FETCH_ASSOC);
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6 mb-3">
|
<div class="col-md-6 mb-3">
|
||||||
<label class="form-label fw-semibold">Department</label>
|
<label class="form-label fw-semibold">Department</label>
|
||||||
<input type="text" class="form-control" id="addDepartment" name="department" placeholder="e.g. Production">
|
<select class="form-select" id="addDepartmentId" name="department_id" style="width:100%;">
|
||||||
|
<option value="">-- Select Department --</option>
|
||||||
|
<?php foreach ($departments as $d): ?>
|
||||||
|
<option value="<?= (int)$d['id'] ?>">
|
||||||
|
<?= htmlspecialchars($d['name']) ?>
|
||||||
|
<?= !empty($d['code']) ? ' (' . htmlspecialchars($d['code']) . ')' : '' ?>
|
||||||
|
</option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6 mb-3">
|
<div class="col-md-6 mb-3">
|
||||||
<label class="form-label fw-semibold">Position</label>
|
<label class="form-label fw-semibold">Position</label>
|
||||||
@ -552,7 +590,7 @@ $allSkills = $stmtSkills->fetchAll(PDO::FETCH_ASSOC);
|
|||||||
|
|
||||||
<!-- MODALE EDIT DIPENDENTE -->
|
<!-- MODALE EDIT DIPENDENTE -->
|
||||||
<div class="modal fade" id="editEmployeeModal" tabindex="-1">
|
<div class="modal fade" id="editEmployeeModal" tabindex="-1">
|
||||||
<div class="modal-dialog modal-dialog-centered">
|
<div class="modal-dialog modal-lg modal-dialog-centered">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header" style="background-color:#cfe3ff;">
|
<div class="modal-header" style="background-color:#cfe3ff;">
|
||||||
<h5 class="modal-title">Modifica Dipendente</h5>
|
<h5 class="modal-title">Modifica Dipendente</h5>
|
||||||
@ -582,7 +620,15 @@ $allSkills = $stmtSkills->fetchAll(PDO::FETCH_ASSOC);
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6 mb-3">
|
<div class="col-md-6 mb-3">
|
||||||
<label class="form-label fw-semibold">Department</label>
|
<label class="form-label fw-semibold">Department</label>
|
||||||
<input type="text" class="form-control" id="editDepartment" name="department">
|
<select class="form-select" id="editDepartmentId" name="department_id" style="width:100%;">
|
||||||
|
<option value="">-- Select Department --</option>
|
||||||
|
<?php foreach ($departments as $d): ?>
|
||||||
|
<option value="<?= (int)$d['id'] ?>">
|
||||||
|
<?= htmlspecialchars($d['name']) ?>
|
||||||
|
<?= !empty($d['code']) ? ' (' . htmlspecialchars($d['code']) . ')' : '' ?>
|
||||||
|
</option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6 mb-3">
|
<div class="col-md-6 mb-3">
|
||||||
<label class="form-label fw-semibold">Position</label>
|
<label class="form-label fw-semibold">Position</label>
|
||||||
@ -669,7 +715,7 @@ $allSkills = $stmtSkills->fetchAll(PDO::FETCH_ASSOC);
|
|||||||
|
|
||||||
|
|
||||||
// Select2 on user selects
|
// Select2 on user selects
|
||||||
$('#addAuthUserId, #editAuthUserId').select2({
|
$('#addAuthUserId, #editAuthUserId, #addDepartmentId, #editDepartmentId').select2({
|
||||||
theme: 'bootstrap-5',
|
theme: 'bootstrap-5',
|
||||||
width: '100%'
|
width: '100%'
|
||||||
});
|
});
|
||||||
@ -684,7 +730,7 @@ $allSkills = $stmtSkills->fetchAll(PDO::FETCH_ASSOC);
|
|||||||
payload.append('employee_code', $("#addEmployeeCode").val().trim());
|
payload.append('employee_code', $("#addEmployeeCode").val().trim());
|
||||||
payload.append('first_name', $("#addFirstName").val().trim());
|
payload.append('first_name', $("#addFirstName").val().trim());
|
||||||
payload.append('last_name', $("#addLastName").val().trim());
|
payload.append('last_name', $("#addLastName").val().trim());
|
||||||
payload.append('department', $("#addDepartment").val().trim());
|
payload.append('department_id', $("#addDepartmentId").val() || '');
|
||||||
payload.append('position', $("#addPosition").val().trim());
|
payload.append('position', $("#addPosition").val().trim());
|
||||||
payload.append('hire_date', $("#addHireDate").val());
|
payload.append('hire_date', $("#addHireDate").val());
|
||||||
payload.append('status', $("#addStatus").val());
|
payload.append('status', $("#addStatus").val());
|
||||||
@ -732,7 +778,7 @@ $allSkills = $stmtSkills->fetchAll(PDO::FETCH_ASSOC);
|
|||||||
$("#editEmployeeCode").val(btn.data("code"));
|
$("#editEmployeeCode").val(btn.data("code"));
|
||||||
$("#editFirstName").val(btn.data("first_name"));
|
$("#editFirstName").val(btn.data("first_name"));
|
||||||
$("#editLastName").val(btn.data("last_name"));
|
$("#editLastName").val(btn.data("last_name"));
|
||||||
$("#editDepartment").val(btn.data("department"));
|
$("#editDepartmentId").val(btn.data("department_id") ? String(btn.data("department_id")) : '').trigger('change');
|
||||||
$("#editPosition").val(btn.data("position"));
|
$("#editPosition").val(btn.data("position"));
|
||||||
$("#editHireDate").val(btn.data("hire_date"));
|
$("#editHireDate").val(btn.data("hire_date"));
|
||||||
$("#editStatus").val(btn.data("status"));
|
$("#editStatus").val(btn.data("status"));
|
||||||
@ -754,7 +800,7 @@ $allSkills = $stmtSkills->fetchAll(PDO::FETCH_ASSOC);
|
|||||||
payload.append('employee_code', $("#editEmployeeCode").val().trim());
|
payload.append('employee_code', $("#editEmployeeCode").val().trim());
|
||||||
payload.append('first_name', $("#editFirstName").val().trim());
|
payload.append('first_name', $("#editFirstName").val().trim());
|
||||||
payload.append('last_name', $("#editLastName").val().trim());
|
payload.append('last_name', $("#editLastName").val().trim());
|
||||||
payload.append('department', $("#editDepartment").val().trim());
|
payload.append('department_id', $("#editDepartmentId").val() || '');
|
||||||
payload.append('position', $("#editPosition").val().trim());
|
payload.append('position', $("#editPosition").val().trim());
|
||||||
payload.append('hire_date', $("#editHireDate").val());
|
payload.append('hire_date', $("#editHireDate").val());
|
||||||
payload.append('status', $("#editStatus").val());
|
payload.append('status', $("#editStatus").val());
|
||||||
|
|||||||
@ -19,7 +19,13 @@ if ($filterSubjectId) {
|
|||||||
$filterMy = !empty($_GET['filter_my']);
|
$filterMy = !empty($_GET['filter_my']);
|
||||||
$filterMyEmployee = null;
|
$filterMyEmployee = null;
|
||||||
if ($filterMy) {
|
if ($filterMy) {
|
||||||
$st = $pdo->prepare("SELECT id, department FROM employees WHERE auth_user_id = ? LIMIT 1");
|
$st = $pdo->prepare("
|
||||||
|
SELECT e.id, dep.name AS department_name
|
||||||
|
FROM employees e
|
||||||
|
LEFT JOIN departments dep ON dep.id = e.department_id
|
||||||
|
WHERE e.auth_user_id = ?
|
||||||
|
LIMIT 1
|
||||||
|
");
|
||||||
$st->execute([(int)$iduserlogin]);
|
$st->execute([(int)$iduserlogin]);
|
||||||
$filterMyEmployee = $st->fetch(PDO::FETCH_ASSOC) ?: null;
|
$filterMyEmployee = $st->fetch(PDO::FETCH_ASSOC) ?: null;
|
||||||
if (!$filterMyEmployee) {
|
if (!$filterMyEmployee) {
|
||||||
@ -32,13 +38,14 @@ $sql = "
|
|||||||
s.name AS subject_name,
|
s.name AS subject_name,
|
||||||
s.color AS subject_color,
|
s.color AS subject_color,
|
||||||
GROUP_CONCAT(DISTINCT CONCAT(e.first_name, ' ', e.last_name) ORDER BY e.first_name SEPARATOR ', ') as responsabili,
|
GROUP_CONCAT(DISTINCT CONCAT(e.first_name, ' ', e.last_name) ORDER BY e.first_name SEPARATOR ', ') as responsabili,
|
||||||
GROUP_CONCAT(DISTINCT e.department ORDER BY e.department SEPARATOR ', ') as reparti_persone,
|
GROUP_CONCAT(DISTINCT dep.name ORDER BY dep.name SEPARATOR ', ') as reparti_persone,
|
||||||
d.departments as reparti_assegnati,
|
d.departments as reparti_assegnati,
|
||||||
(SELECT COUNT(*) FROM scad_deadline_attachments att WHERE att.deadline_id = d.id) as attachment_count
|
(SELECT COUNT(*) FROM scad_deadline_attachments att WHERE att.deadline_id = d.id) as attachment_count
|
||||||
FROM scad_deadlines d
|
FROM scad_deadlines d
|
||||||
LEFT JOIN scad_subjects s ON s.id = d.subject_id
|
LEFT JOIN scad_subjects s ON s.id = d.subject_id
|
||||||
LEFT JOIN scad_deadline_employee de ON de.deadline_id = d.id
|
LEFT JOIN scad_deadline_employee de ON de.deadline_id = d.id
|
||||||
LEFT JOIN employees e ON e.id = de.employee_id
|
LEFT JOIN employees e ON e.id = de.employee_id
|
||||||
|
LEFT JOIN departments dep ON dep.id = e.department_id
|
||||||
";
|
";
|
||||||
$where = [];
|
$where = [];
|
||||||
$params = [];
|
$params = [];
|
||||||
@ -50,8 +57,8 @@ if ($filterMy && $filterMyEmployee) {
|
|||||||
$where[] = "(d.id IN (SELECT deadline_id FROM scad_deadline_employee WHERE employee_id = ?)"
|
$where[] = "(d.id IN (SELECT deadline_id FROM scad_deadline_employee WHERE employee_id = ?)"
|
||||||
. " OR (? <> '' AND FIND_IN_SET(?, REPLACE(d.departments, ', ', ',')) > 0))";
|
. " OR (? <> '' AND FIND_IN_SET(?, REPLACE(d.departments, ', ', ',')) > 0))";
|
||||||
$params[] = (int)$filterMyEmployee['id'];
|
$params[] = (int)$filterMyEmployee['id'];
|
||||||
$params[] = (string)($filterMyEmployee['department'] ?? '');
|
$params[] = (string)($filterMyEmployee['department_name'] ?? '');
|
||||||
$params[] = (string)($filterMyEmployee['department'] ?? '');
|
$params[] = (string)($filterMyEmployee['department_name'] ?? '');
|
||||||
}
|
}
|
||||||
if (!empty($where)) {
|
if (!empty($where)) {
|
||||||
$sql .= " WHERE " . implode(' AND ', $where);
|
$sql .= " WHERE " . implode(' AND ', $where);
|
||||||
@ -62,9 +69,25 @@ $stmt = $pdo->prepare($sql);
|
|||||||
$stmt->execute($params);
|
$stmt->execute($params);
|
||||||
$deadlines = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$deadlines = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
$employees = $pdo->query("SELECT id, first_name, last_name, department FROM employees WHERE status = 'active' ORDER BY first_name")->fetchAll(PDO::FETCH_ASSOC);
|
$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);
|
||||||
|
|
||||||
$departments = $pdo->query("SELECT DISTINCT department FROM employees WHERE department IS NOT NULL AND department != '' ORDER BY department")->fetchAll(PDO::FETCH_COLUMN);
|
$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);
|
||||||
|
|
||||||
$subjects = $pdo->query("SELECT id, name, color FROM scad_subjects ORDER BY name")->fetchAll(PDO::FETCH_ASSOC);
|
$subjects = $pdo->query("SELECT id, name, color FROM scad_subjects ORDER BY name")->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
@ -678,7 +701,7 @@ function getContrastTextColor($hexColor)
|
|||||||
<div>
|
<div>
|
||||||
<i class="fa-solid fa-user-check me-2"></i>
|
<i class="fa-solid fa-user-check me-2"></i>
|
||||||
<strong>Le mie scadenze</strong>
|
<strong>Le mie scadenze</strong>
|
||||||
<span class="text-muted ms-2">(assegnate a me o al reparto <?= htmlspecialchars($filterMyEmployee['department'] ?? '—', ENT_QUOTES, 'UTF-8') ?>)</span>
|
<span class="text-muted ms-2">(assegnate a me o al reparto <?= htmlspecialchars($filterMyEmployee['department_name'] ?? '—', ENT_QUOTES, 'UTF-8') ?>)</span>
|
||||||
</div>
|
</div>
|
||||||
<a href="scadenzario/index.php" class="btn btn-sm btn-light border">
|
<a href="scadenzario/index.php" class="btn btn-sm btn-light border">
|
||||||
<i class="fa-solid fa-xmark me-1"></i> Tutte le scadenze
|
<i class="fa-solid fa-xmark me-1"></i> Tutte le scadenze
|
||||||
@ -755,7 +778,10 @@ function getContrastTextColor($hexColor)
|
|||||||
<select id="filterDepartment" class="form-select">
|
<select id="filterDepartment" class="form-select">
|
||||||
<option value="">Tutti</option>
|
<option value="">Tutti</option>
|
||||||
<?php foreach ($departments as $dept): ?>
|
<?php foreach ($departments as $dept): ?>
|
||||||
<option value="<?= htmlspecialchars($dept, ENT_QUOTES, 'UTF-8') ?>"><?= htmlspecialchars($dept, ENT_QUOTES, 'UTF-8') ?></option>
|
<option value="<?= htmlspecialchars($dept['name'], ENT_QUOTES, 'UTF-8') ?>">
|
||||||
|
<?= htmlspecialchars($dept['name'], ENT_QUOTES, 'UTF-8') ?>
|
||||||
|
<?= !empty($dept['code']) ? ' (' . htmlspecialchars($dept['code'], ENT_QUOTES, 'UTF-8') . ')' : '' ?>
|
||||||
|
</option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@ -1108,7 +1134,10 @@ function getContrastTextColor($hexColor)
|
|||||||
<label for="dlDepartments" class="form-label fw-semibold">Reparti</label>
|
<label for="dlDepartments" class="form-label fw-semibold">Reparti</label>
|
||||||
<select class="form-select" id="dlDepartments" name="department_names[]" multiple>
|
<select class="form-select" id="dlDepartments" name="department_names[]" multiple>
|
||||||
<?php foreach ($departments as $dept): ?>
|
<?php foreach ($departments as $dept): ?>
|
||||||
<option value="<?= htmlspecialchars($dept, ENT_QUOTES, 'UTF-8') ?>"><?= htmlspecialchars($dept, ENT_QUOTES, 'UTF-8') ?></option>
|
<option value="<?= htmlspecialchars($dept['name'], ENT_QUOTES, 'UTF-8') ?>">
|
||||||
|
<?= htmlspecialchars($dept['name'], ENT_QUOTES, 'UTF-8') ?>
|
||||||
|
<?= !empty($dept['code']) ? ' (' . htmlspecialchars($dept['code'], ENT_QUOTES, 'UTF-8') . ')' : '' ?>
|
||||||
|
</option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
<div class="form-text">Tutto il reparto sarà responsabile</div>
|
<div class="form-text">Tutto il reparto sarà responsabile</div>
|
||||||
@ -1118,7 +1147,7 @@ function getContrastTextColor($hexColor)
|
|||||||
<select class="form-select" id="dlEmployees" name="employee_ids[]" multiple>
|
<select class="form-select" id="dlEmployees" name="employee_ids[]" multiple>
|
||||||
<?php foreach ($employees as $emp): ?>
|
<?php foreach ($employees as $emp): ?>
|
||||||
<option value="<?= (int)$emp['id'] ?>">
|
<option value="<?= (int)$emp['id'] ?>">
|
||||||
<?= htmlspecialchars($emp['first_name'] . ' ' . $emp['last_name'], ENT_QUOTES, 'UTF-8') ?><?php if ($emp['department']): ?> (<?= htmlspecialchars($emp['department'], ENT_QUOTES, 'UTF-8') ?>)<?php endif; ?>
|
<?= htmlspecialchars($emp['first_name'] . ' ' . $emp['last_name'], ENT_QUOTES, 'UTF-8') ?><?php if (!empty($emp['department_name'])): ?> (<?= htmlspecialchars($emp['department_name'], ENT_QUOTES, 'UTF-8') ?>)<?php endif; ?>
|
||||||
</option>
|
</option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user