From ac942dcdc87dbcc617e02cc66cca0dc7e713fed8 Mon Sep 17 00:00:00 2001 From: solocla Date: Thu, 7 May 2026 09:44:38 +0200 Subject: [PATCH] added depart,ments to employee and deadlines --- public/userarea/employees.php | 82 +++++++++++++++++++++------ public/userarea/scadenzario/index.php | 49 ++++++++++++---- 2 files changed, 103 insertions(+), 28 deletions(-) diff --git a/public/userarea/employees.php b/public/userarea/employees.php index 1b15cea..ce02399 100644 --- a/public/userarea/employees.php +++ b/public/userarea/employees.php @@ -21,7 +21,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['ajax']) && $_POST['aj $employee_code = trim($_POST['employee_code'] ?? ''); $first_name = trim($_POST['first_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'] ?? ''); $hire_date = trim($_POST['hire_date'] ?? ''); $status = trim($_POST['status'] ?? 'active'); @@ -40,16 +40,16 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['ajax']) && $_POST['aj } $sql = "INSERT INTO employees - (auth_user_id, employee_code, first_name, last_name, department, position, hire_date, status, created_at, updated_at) - 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, created_at, updated_at) + VALUES + (:auth_user_id, :employee_code, :first_name, :last_name, :department_id, :position, :hire_date, :status, NOW(), NOW())"; $stmt = $pdo->prepare($sql); $stmt->execute([ 'auth_user_id' => $auth_user_id, 'employee_code' => $employee_code !== '' ? $employee_code : null, 'first_name' => $first_name, 'last_name' => $last_name, - 'department' => $department !== '' ? $department : null, + 'department_id' => $department_id, 'position' => $position !== '' ? $position : null, 'hire_date' => $hire_date !== '' ? $hire_date : null, 'status' => $status @@ -65,7 +65,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['ajax']) && $_POST['aj $employee_code = trim($_POST['employee_code'] ?? ''); $first_name = trim($_POST['first_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'] ?? ''); $hire_date = trim($_POST['hire_date'] ?? ''); $status = trim($_POST['status'] ?? 'active'); @@ -93,7 +93,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['ajax']) && $_POST['aj employee_code = :employee_code, first_name = :first_name, last_name = :last_name, - department = :department, + department_id = :department_id, position = :position, hire_date = :hire_date, status = :status, @@ -105,7 +105,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['ajax']) && $_POST['aj 'employee_code' => $employee_code !== '' ? $employee_code : null, 'first_name' => $first_name, 'last_name' => $last_name, - 'department' => $department !== '' ? $department : null, + 'department_id' => $department_id, 'position' => $position !== '' ? $position : null, 'hire_date' => $hire_date !== '' ? $hire_date : null, 'status' => $status, @@ -193,9 +193,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['ajax']) && $_POST['aj // Employees list $sql = " SELECT e.*, + d.name AS department_name, + d.color AS department_color, au.email AS user_email, CONCAT(COALESCE(au.first_name, ''), ' ', COALESCE(au.last_name, '')) AS user_fullname 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 ORDER BY e.id DESC "; @@ -219,6 +222,16 @@ $sqlUsers = " $stmtUsers = $pdo->query($sqlUsers); $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 $sqlSkills = " 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; 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; + } @@ -421,7 +443,15 @@ $allSkills = $stmtSkills->fetchAll(PDO::FETCH_ASSOC); - + + + + + + + - + + @@ -437,7 +467,7 @@ $allSkills = $stmtSkills->fetchAll(PDO::FETCH_ASSOC); data-code="" data-first_name="" data-last_name="" - data-department="" + data-department_id="" data-position="" data-hire_date="" data-status="" @@ -477,7 +507,7 @@ $allSkills = $stmtSkills->fetchAll(PDO::FETCH_ASSOC);