diff --git a/public/userarea/employee-profile.php b/public/userarea/employee-profile.php index a00ef9f..3727328 100644 --- a/public/userarea/employee-profile.php +++ b/public/userarea/employee-profile.php @@ -169,33 +169,47 @@ $rolesList = $isHrManager /* ========================================== HELPERS ========================================== */ -function statusBadge(string $status): array { +function statusBadge(string $status): array +{ switch ($status) { - case 'active': return ['label' => 'Attivo', 'class' => 'success']; - case 'inactive': return ['label' => 'Cessato', 'class' => 'secondary']; - case 'suspended': return ['label' => 'Sospeso', 'class' => 'warning']; - default: return ['label' => htmlspecialchars($status), 'class' => 'secondary']; + case 'active': + return ['label' => 'Attivo', 'class' => 'success']; + case 'inactive': + return ['label' => 'Cessato', 'class' => 'secondary']; + case 'suspended': + return ['label' => 'Sospeso', 'class' => 'warning']; + default: + return ['label' => htmlspecialchars($status), 'class' => 'secondary']; } } -function fmtDate(?string $d): string { +function fmtDate(?string $d): string +{ if (!$d || $d === '0000-00-00') return '—'; $ts = strtotime($d); return $ts ? date('d/m/Y', $ts) : '—'; } -function valOrDash($v): string { +function valOrDash($v): string +{ $v = (string)($v ?? ''); return $v !== '' ? htmlspecialchars($v) : '—'; } -function categoryLabel(string $c): string { +function categoryLabel(string $c): string +{ switch ($c) { - case 'job_description': return 'Mansionario'; - case 'contract': return 'Contratto'; - case 'rules': return 'Regolamento'; - case 'other': return 'Altro'; - default: return htmlspecialchars($c); + case 'job_description': + return 'Mansionario'; + case 'contract': + return 'Contratto'; + case 'rules': + return 'Regolamento'; + case 'other': + return 'Altro'; + default: + return htmlspecialchars($c); } } -function trainingStatus(?string $nextDue, ?int $reminderDays, ?int $topicDefaultRem): array { +function trainingStatus(?string $nextDue, ?int $reminderDays, ?int $topicDefaultRem): array +{ if (!$nextDue) { return ['code' => 'compliant', 'label' => 'Conforme', 'class' => 'success']; } @@ -208,7 +222,8 @@ function trainingStatus(?string $nextDue, ?int $reminderDays, ?int $topicDefault if ($daysLeft <= $rem) return ['code' => 'due_soon', 'label' => 'Da aggiornare', 'class' => 'warning']; return ['code' => 'compliant', 'label' => 'Conforme', 'class' => 'success']; } -function fmtFileSize(?int $bytes): string { +function fmtFileSize(?int $bytes): string +{ if ($bytes === null || $bytes <= 0) return '—'; if ($bytes < 1024) return $bytes . ' B'; if ($bytes < 1024 * 1024) return number_format($bytes / 1024, 1) . ' KB'; @@ -224,25 +239,55 @@ function fmtFileSize(?int $bytes): string { + Profilo Dipendente - <?= htmlspecialchars($titlewebsite, ENT_QUOTES, 'UTF-8'); ?> @@ -458,16 +715,28 @@ function fmtFileSize(?int $bytes): string { $deptName = $employee['department_name'] ?? null; $deptColor = $employee['department_color'] ?? null; $jobName = $employee['job_role_name'] ?? null; - $avatar = $employee['auth_avatar'] ?? null; + + $avatar = trim((string)($employee['auth_avatar'] ?? '')); + + if ($avatar !== '') { + // If the DB stores only the filename, build the correct relative path. + if ( + strpos($avatar, '/') === false && + strpos($avatar, '\\') === false && + !preg_match('/^https?:\/\//i', $avatar) + ) { + $avatar = '../upload/users/' . $avatar; + } + } ?>
- - avatar + + user avatar - +
@@ -569,7 +838,7 @@ function fmtFileSize(?int $bytes): string {
- +
@@ -577,7 +846,7 @@ function fmtFileSize(?int $bytes): string {
- +
@@ -631,7 +900,7 @@ function fmtFileSize(?int $bytes): string {
- +
@@ -654,7 +923,7 @@ function fmtFileSize(?int $bytes): string {
Categoria + class="fw-semibold text-decoration-none"> @@ -666,11 +935,11 @@ function fmtFileSize(?int $bytes): string { ⬇️ Scarica + href="ajax/employee_profile/download_document.php?id=">⬇️ Scarica @@ -696,7 +965,7 @@ function fmtFileSize(?int $bytes): string { + class="doc-card-title"> @@ -708,11 +977,11 @@ function fmtFileSize(?int $bytes): string {
⬇️ Scarica + href="ajax/employee_profile/download_document.php?id=">⬇️ Scarica @@ -865,7 +1134,7 @@ function fmtFileSize(?int $bytes): string {
- +
@@ -882,9 +1151,11 @@ function fmtFileSize(?int $bytes): string { 'storico', 'label' => 'Storico', 'class' => 'secondary']; $typeLabel = $t['training_type'] === 'refresher' ? 'Aggiornamento' : 'Iniziale'; ?> @@ -931,9 +1202,11 @@ function fmtFileSize(?int $bytes): string { 'storico', 'label' => 'Storico', 'class' => 'secondary']; $typeLabel = $t['training_type'] === 'refresher' ? 'Aggiornamento' : 'Iniziale'; ?> @@ -1020,19 +1293,76 @@ function fmtFileSize(?int $bytes): string { background: #f8fafc; border-radius: 0 10px 10px 0; } - .log-entry.created { border-left-color: #16a34a; } - .log-entry.updated { border-left-color: #2563eb; } - .log-entry.deleted { border-left-color: #dc2626; } - .log-entry.attachment_added { border-left-color: #0891b2; } - .log-entry.attachment_deleted { border-left-color: #ea580c; } - .log-when { font-size: 0.85rem; color: #64748b; } - .log-who { font-weight: 600; color: #1f2937; } - .log-action { font-weight: 600; } - .log-field { color: #475569; font-size: 0.95rem; margin-top: 4px; } - .log-field code { background: #e2e8f0; padding: 2px 6px; border-radius: 4px; } - .log-diff { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 4px; font-size: 0.9rem; } - .log-old { background: #fee2e2; color: #991b1b; padding: 2px 8px; border-radius: 4px; text-decoration: line-through; } - .log-new { background: #dcfce7; color: #166534; padding: 2px 8px; border-radius: 4px; } + + .log-entry.created { + border-left-color: #16a34a; + } + + .log-entry.updated { + border-left-color: #2563eb; + } + + .log-entry.deleted { + border-left-color: #dc2626; + } + + .log-entry.attachment_added { + border-left-color: #0891b2; + } + + .log-entry.attachment_deleted { + border-left-color: #ea580c; + } + + .log-when { + font-size: 0.85rem; + color: #64748b; + } + + .log-who { + font-weight: 600; + color: #1f2937; + } + + .log-action { + font-weight: 600; + } + + .log-field { + color: #475569; + font-size: 0.95rem; + margin-top: 4px; + } + + .log-field code { + background: #e2e8f0; + padding: 2px 6px; + border-radius: 4px; + } + + .log-diff { + display: flex; + gap: 6px; + flex-wrap: wrap; + align-items: center; + margin-top: 4px; + font-size: 0.9rem; + } + + .log-old { + background: #fee2e2; + color: #991b1b; + padding: 2px 8px; + border-radius: 4px; + text-decoration: line-through; + } + + .log-new { + background: #dcfce7; + color: #166534; + padding: 2px 8px; + border-radius: 4px; + } @@ -1317,8 +1647,8 @@ function fmtFileSize(?int $bytes): string {
@@ -1366,640 +1696,861 @@ function fmtFileSize(?int $bytes): string { - - + + + + + })(); + - + - + + \ No newline at end of file
Corso