trainings changed details

This commit is contained in:
2026-05-26 16:55:04 +02:00
parent fdc3af01f3
commit 70b712ff3b
4 changed files with 913 additions and 183 deletions
+84 -18
View File
@@ -150,7 +150,7 @@ $dashboardSections = [
[
'id' => 'secPersonale',
'title' => 'Personale',
'subtitle' => 'Dipendenti, skill',
'subtitle' => 'Dipendenti, formazione, skill',
'icon' => '👥',
'open' => false,
'buttons' => [
@@ -168,6 +168,20 @@ $dashboardSections = [
'url' => 'departments.php',
'permission' => 'hr.departments.view',
],
[
'label' => 'Corsi Formazione',
'icon' => '📚',
'class' => 'btn-setup',
'url' => 'training_topics.php',
'permission' => 'hr.training_topics.view',
],
[
'label' => 'Storico Formazione',
'icon' => '🎓',
'class' => 'btn-setup',
'url' => 'trainings.php',
'permission' => 'hr.trainings.view',
],
[
'label' => 'Skills',
'icon' => '🧠',
@@ -494,45 +508,97 @@ $dashboardSections = [
margin-bottom: 1rem;
width: 100%;
}
.my-deadlines-widgets:empty { display: none; }
.my-deadlines-widgets:empty {
display: none;
}
/* Each widget wraps itself in .my-deadlines-widgets; collapse the nested
wrapper so all cards flow into the outer flex (single row). */
.my-deadlines-widgets .my-deadlines-widgets {
display: contents;
}
.my-deadlines-widgets .mdw {
flex: 1 1 0;
min-width: 0;
display: flex; align-items: center; gap: 0.75rem;
display: flex;
align-items: center;
gap: 0.75rem;
padding: 0.8rem 0.9rem;
border-radius: 0.6rem;
text-decoration: none;
color: #fff;
box-shadow: 0 2px 6px rgba(0,0,0,0.08);
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
transition: transform 0.15s, box-shadow 0.15s;
}
@media (max-width: 991.98px) {
.my-deadlines-widgets .mdw { flex: 1 1 calc(50% - 0.375rem); }
.my-deadlines-widgets .mdw {
flex: 1 1 calc(50% - 0.375rem);
}
}
@media (max-width: 575.98px) {
.my-deadlines-widgets .mdw { flex: 1 1 100%; }
.my-deadlines-widgets .mdw {
flex: 1 1 100%;
}
}
.my-deadlines-widgets .mdw:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.15); color: #fff; }
.my-deadlines-widgets .mdw-red { background: linear-gradient(135deg, #dc3545 0%, #b02a37 100%); }
.my-deadlines-widgets .mdw-orange { background: linear-gradient(135deg, #e8930c 0%, #c77a00 100%); }
.my-deadlines-widgets .mdw-gray { background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%); }
.my-deadlines-widgets .mdw:hover {
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
color: #fff;
}
.my-deadlines-widgets .mdw-red {
background: linear-gradient(135deg, #dc3545 0%, #b02a37 100%);
}
.my-deadlines-widgets .mdw-orange {
background: linear-gradient(135deg, #e8930c 0%, #c77a00 100%);
}
.my-deadlines-widgets .mdw-gray {
background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
}
.my-deadlines-widgets .mdw-icon {
width: 38px; height: 38px; border-radius: 50%;
display: flex; align-items: center; justify-content: center;
background: rgba(255,255,255,0.22); font-size: 1.05rem; flex-shrink: 0;
width: 38px;
height: 38px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
background: rgba(255, 255, 255, 0.22);
font-size: 1.05rem;
flex-shrink: 0;
}
.my-deadlines-widgets .mdw-body { flex: 1; line-height: 1.2; min-width: 0; }
.my-deadlines-widgets .mdw-count { font-size: 1.5rem; font-weight: 700; }
.my-deadlines-widgets .mdw-body {
flex: 1;
line-height: 1.2;
min-width: 0;
}
.my-deadlines-widgets .mdw-count {
font-size: 1.5rem;
font-weight: 700;
}
.my-deadlines-widgets .mdw-label {
font-size: 0.78rem; opacity: 0.95;
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
font-size: 0.78rem;
opacity: 0.95;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.my-deadlines-widgets .mdw-arrow {
opacity: 0.7;
font-size: 0.85rem;
flex-shrink: 0;
}
.my-deadlines-widgets .mdw-arrow { opacity: 0.7; font-size: 0.85rem; flex-shrink: 0; }
</style>
<div class="my-deadlines-widgets">
<?php include(__DIR__ . '/scadenzario/include/my_deadlines_widget.php'); ?>
+179 -32
View File
@@ -43,37 +43,172 @@ $departments = $pdo->query("
<title>Calendario Formazione - <?= htmlspecialchars($titlewebsite, ENT_QUOTES, 'UTF-8'); ?></title>
<style>
body { font-size: 1.05rem; background: #f8fafc; }
.card { border-radius: 16px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); }
.back-dashboard {
background-color: #cfe3ff !important; color: #1f2d3d !important;
border: 1px solid #bcd4f4 !important; border-radius: 10px;
font-weight: 600; padding: 10px 18px;
body {
font-size: 1.05rem;
background: #f8fafc;
}
.legend { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 1rem; }
.legend-item { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: #64748b; }
.legend-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
/* FullCalendar overrides */
.fc { font-size: 0.95rem; }
.fc .fc-toolbar-title { font-size: 1.15rem; font-weight: 700; color: #2c3e6b; }
.fc .fc-button-primary {
background: #5a8fd8; border-color: #5a8fd8;
font-weight: 600; font-size: 0.82rem; border-radius: 0.4rem;
.card {
border-radius: 16px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
.back-dashboard {
background-color: #cfe3ff !important;
color: #1f2d3d !important;
border: 1px solid #bcd4f4 !important;
border-radius: 10px;
font-weight: 600;
padding: 10px 18px;
}
.training-header-actions {
display: flex;
align-items: center;
gap: 8px;
flex-wrap: wrap;
}
.btn-training-action {
border-radius: 10px;
font-weight: 500;
padding: 10px 16px;
box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
transition: all 0.2s ease-in-out;
color: #fff !important;
text-decoration: none;
}
.btn-training-action:hover {
transform: translateY(-2px);
color: #fff !important;
}
.btn-training-topics {
background-color: #0d6efd !important;
border: 1px solid #0b5ed7 !important;
}
.btn-training-topics:hover {
background-color: #0b5ed7 !important;
}
.btn-training-history {
background-color: #2563eb !important;
border: 1px solid #1d4ed8 !important;
}
.btn-training-history:hover {
background-color: #1d4ed8 !important;
}
.fc .fc-button-primary:hover { background: #4578c0; border-color: #4578c0; }
.fc .fc-button-primary:disabled { background: #9bbce6; border-color: #9bbce6; }
.fc .fc-button-primary:not(:disabled).fc-button-active { background: #2c3e6b; border-color: #2c3e6b; }
.fc .fc-daygrid-day-number { color: #2c3e6b; font-weight: 500; }
.fc .fc-daygrid-day.fc-day-today { background: #f0f4ff; }
.fc .fc-event { border-radius: 0.3rem; padding: 2px 4px; font-weight: 600; cursor: pointer; }
.fc .fc-event:hover { filter: brightness(0.92); }
.fc .fc-list-event:hover td { background: #f0f4ff; }
@media (max-width: 767.98px) {
.card-header { flex-direction: column; align-items: flex-start !important; gap: .5rem; }
.fc .fc-toolbar { flex-direction: column; gap: 0.5rem; }
.fc .fc-toolbar-title { font-size: 1rem; }
.training-header-actions {
width: 100%;
flex-direction: column;
}
.training-header-actions .btn,
.training-header-actions a {
width: 100%;
}
}
.legend {
display: flex;
flex-wrap: wrap;
gap: 1rem;
margin-bottom: 1rem;
}
.legend-item {
display: flex;
align-items: center;
gap: 0.4rem;
font-size: 0.85rem;
color: #64748b;
}
.legend-dot {
width: 12px;
height: 12px;
border-radius: 50%;
flex-shrink: 0;
}
/* FullCalendar overrides */
.fc {
font-size: 0.95rem;
}
.fc .fc-toolbar-title {
font-size: 1.15rem;
font-weight: 700;
color: #2c3e6b;
}
.fc .fc-button-primary {
background: #5a8fd8;
border-color: #5a8fd8;
font-weight: 600;
font-size: 0.82rem;
border-radius: 0.4rem;
}
.fc .fc-button-primary:hover {
background: #4578c0;
border-color: #4578c0;
}
.fc .fc-button-primary:disabled {
background: #9bbce6;
border-color: #9bbce6;
}
.fc .fc-button-primary:not(:disabled).fc-button-active {
background: #2c3e6b;
border-color: #2c3e6b;
}
.fc .fc-daygrid-day-number {
color: #2c3e6b;
font-weight: 500;
}
.fc .fc-daygrid-day.fc-day-today {
background: #f0f4ff;
}
.fc .fc-event {
border-radius: 0.3rem;
padding: 2px 4px;
font-weight: 600;
cursor: pointer;
}
.fc .fc-event:hover {
filter: brightness(0.92);
}
.fc .fc-list-event:hover td {
background: #f0f4ff;
}
@media (max-width: 767.98px) {
.card-header {
flex-direction: column;
align-items: flex-start !important;
gap: .5rem;
}
.fc .fc-toolbar {
flex-direction: column;
gap: 0.5rem;
}
.fc .fc-toolbar-title {
font-size: 1rem;
}
}
</style>
</head>
@@ -88,10 +223,20 @@ $departments = $pdo->query("
<div class="card p-3">
<div class="card-header d-flex justify-content-between align-items-center flex-wrap gap-2">
<h5 class="mb-0">📅 Calendario Formazione</h5>
<div class="d-flex gap-2 flex-wrap">
<a href="trainings.php" class="btn btn-light border d-inline-flex align-items-center gap-2">
📚 <span>Storico Formazione</span>
</a>
<div class="training-header-actions">
<?php if (userCan('hr.training_topics.view')): ?>
<a href="training_topics.php" class="btn btn-training-action btn-training-topics">
📘 Corsi Formazione
</a>
<?php endif; ?>
<?php if (userCan('hr.trainings.view')): ?>
<a href="trainings.php" class="btn btn-training-action btn-training-history">
📚 Gestione Formazione
</a>
<?php endif; ?>
<button type="button" class="btn back-dashboard" onclick="location.href='production_dashboard.php'">
↩️ Torna alla Dashboard
</button>
@@ -201,7 +346,9 @@ $departments = $pdo->query("
calendar.render();
document.querySelectorAll('#filterStatus, #filterTopic, #filterDepartment, #filterEmployee').forEach(function(el) {
el.addEventListener('change', function() { calendar.refetchEvents(); });
el.addEventListener('change', function() {
calendar.refetchEvents();
});
});
document.getElementById('btnResetFilters').addEventListener('click', function() {
@@ -214,4 +361,4 @@ $departments = $pdo->query("
</script>
</body>
</html>
</html>
+250 -48
View File
@@ -33,36 +33,193 @@ $topics = $pdo->query($sql)->fetchAll(PDO::FETCH_ASSOC);
<script src="https://cdn.datatables.net/1.13.6/js/dataTables.bootstrap5.min.js"></script>
<style>
body { font-size: 1.05rem; background: #f8fafc; }
.card { border-radius: 16px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); }
body {
font-size: 1.05rem;
background: #f8fafc;
}
.card {
border-radius: 16px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
.back-dashboard {
background-color: #cfe3ff !important; color: #1f2d3d !important;
border: 1px solid #bcd4f4 !important; border-radius: 10px;
font-weight: 600; padding: 10px 18px;
background-color: #cfe3ff !important;
color: #1f2d3d !important;
border: 1px solid #bcd4f4 !important;
border-radius: 10px;
font-weight: 600;
padding: 10px 18px;
box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
transition: all 0.2s ease-in-out;
}
.back-dashboard:hover { background-color: #b9d3ff !important; transform: translateY(-2px); }
.btn-add { background-color: #0d6efd; color: #fff; border-radius: 8px; padding: 10px 20px; font-weight: 500; }
.btn-add:hover { background-color: #0b5ed7; transform: scale(1.02); }
.table thead { background-color: #cfe3ff; color: #1f2d3d; }
.modal-content { border-radius: 16px; }
#tabellaTopics thead th { text-align: center; vertical-align: middle; }
.badge-status { padding: 0.25rem 0.6rem; border-radius: 999px; font-size: 0.8rem; font-weight: 600; }
.badge-status.active { background-color: #d1fae5; color: #065f46; }
.badge-status.inactive { background-color: #e5e7eb; color: #374151; }
.description-cell {
max-width: 280px; white-space: nowrap; overflow: hidden;
text-overflow: ellipsis; text-align: left;
.back-dashboard:hover {
background-color: #b9d3ff !important;
transform: translateY(-2px);
}
.num-pill {
display: inline-block; padding: 2px 10px; border-radius: 999px;
background: #eef2ff; color: #3730a3; font-weight: 600; font-size: 0.85rem;
.training-header-actions {
display: flex;
align-items: center;
gap: 8px;
flex-wrap: wrap;
}
.btn-training-action {
border-radius: 10px;
font-weight: 500;
padding: 10px 16px;
box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
transition: all 0.2s ease-in-out;
color: #fff !important;
}
.btn-training-action:hover {
transform: translateY(-2px);
color: #fff !important;
}
.btn-training-history {
background-color: #0d6efd !important;
border: 1px solid #0b5ed7 !important;
}
.btn-training-history:hover {
background-color: #0b5ed7 !important;
}
.btn-training-calendar {
background-color: #2563eb !important;
border: 1px solid #1d4ed8 !important;
}
.btn-training-calendar:hover {
background-color: #1d4ed8 !important;
}
@media (max-width: 767.98px) {
.card-header { flex-direction: column; align-items: flex-start !important; gap: .5rem; }
.back-dashboard { width: 100%; }
.btn-add { width: 100%; }
.training-header-actions {
width: 100%;
flex-direction: column;
}
.training-header-actions .btn {
width: 100%;
}
}
.btn-add {
background-color: #0d6efd;
color: #fff;
border-radius: 8px;
padding: 10px 20px;
font-weight: 500;
}
.btn-add:hover {
background-color: #0b5ed7;
transform: scale(1.02);
}
.training-shortcuts {
display: flex;
flex-wrap: wrap;
gap: 10px;
margin-bottom: 18px;
}
.training-shortcut-btn {
display: inline-flex;
align-items: center;
gap: 8px;
border-radius: 10px;
padding: 10px 16px;
font-weight: 600;
text-decoration: none;
border: 1px solid #bcd4f4;
background: #cfe3ff;
color: #1f2d3d;
box-shadow: 0 3px 8px rgba(0, 0, 0, .08);
transition: all .2s ease-in-out;
}
.training-shortcut-btn:hover {
background: #b9d3ff;
color: #1f2d3d;
transform: translateY(-2px);
}
@media (max-width: 767.98px) {
.training-shortcut-btn {
width: 100%;
justify-content: center;
}
}
.table thead {
background-color: #cfe3ff;
color: #1f2d3d;
}
.modal-content {
border-radius: 16px;
}
#tabellaTopics thead th {
text-align: center;
vertical-align: middle;
}
.badge-status {
padding: 0.25rem 0.6rem;
border-radius: 999px;
font-size: 0.8rem;
font-weight: 600;
}
.badge-status.active {
background-color: #d1fae5;
color: #065f46;
}
.badge-status.inactive {
background-color: #e5e7eb;
color: #374151;
}
.description-cell {
max-width: 280px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
text-align: left;
}
.num-pill {
display: inline-block;
padding: 2px 10px;
border-radius: 999px;
background: #eef2ff;
color: #3730a3;
font-weight: 600;
font-size: 0.85rem;
}
@media (max-width: 767.98px) {
.card-header {
flex-direction: column;
align-items: flex-start !important;
gap: .5rem;
}
.back-dashboard {
width: 100%;
}
.btn-add {
width: 100%;
}
}
.tt-card {
@@ -73,6 +230,7 @@ $topics = $pdo->query($sql)->fetchAll(PDO::FETCH_ASSOC);
background: #fff;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}
.tt-card-title {
font-size: 1.1rem;
font-weight: 600;
@@ -80,12 +238,14 @@ $topics = $pdo->query($sql)->fetchAll(PDO::FETCH_ASSOC);
margin: 0 0 4px 0;
word-break: break-word;
}
.tt-card-desc {
color: #475569;
font-size: 0.95rem;
margin: 0 0 10px 0;
word-break: break-word;
}
.tt-card-meta {
display: flex;
flex-wrap: wrap;
@@ -94,12 +254,21 @@ $topics = $pdo->query($sql)->fetchAll(PDO::FETCH_ASSOC);
color: #64748b;
margin-bottom: 12px;
}
.tt-card-meta b { color: #1f2937; font-weight: 600; }
.tt-card-meta b {
color: #1f2937;
font-weight: 600;
}
.tt-card-actions {
display: flex;
gap: 8px;
}
.tt-card-actions .btn { flex: 1; }
.tt-card-actions .btn {
flex: 1;
}
.tt-empty {
text-align: center;
color: #94a3b8;
@@ -117,13 +286,28 @@ $topics = $pdo->query($sql)->fetchAll(PDO::FETCH_ASSOC);
<div class="page-content">
<div class="card p-3">
<div class="card-header d-flex justify-content-between align-items-center flex-wrap gap-2">
<h5 class="mb-0">Gestione Corsi di Formazione</h5>
<button type="button" class="btn back-dashboard" onclick="location.href='production_dashboard.php'">
↩️ Torna alla Dashboard
</button>
<h5 class="mb-0">Corsi Formazione</h5>
<div class="training-header-actions">
<?php if (userCan('hr.trainings.view')): ?>
<a href="trainings.php" class="btn btn-training-action btn-training-history">
🎓 Gestione Formazione
</a>
<a href="training_calendar.php" class="btn btn-training-action btn-training-calendar">
📅 Calendario Formazione
</a>
<?php endif; ?>
<button type="button" class="btn back-dashboard" onclick="location.href='production_dashboard.php'">
↩️ Torna alla Dashboard
</button>
</div>
</div>
<div class="card-body">
<div class="d-flex justify-content-between align-items-center mb-3 flex-wrap gap-2">
<h6 class="fw-semibold mb-0">Elenco Corsi / Training Topics</h6>
<button class="btn btn-add" data-bs-toggle="modal" data-bs-target="#addTopicModal">
@@ -420,7 +604,10 @@ $topics = $pdo->query($sql)->fetchAll(PDO::FETCH_ASSOC);
<script>
$(document).ready(function() {
$('#tabellaTopics').DataTable({
order: [[5, 'asc'], [1, 'asc']],
order: [
[5, 'asc'],
[1, 'asc']
],
pageLength: 25,
language: {
url: 'https://cdn.datatables.net/plug-ins/1.13.6/i18n/it-IT.json',
@@ -430,23 +617,37 @@ $topics = $pdo->query($sql)->fetchAll(PDO::FETCH_ASSOC);
function ajaxPost(url, payload, successTitle, errorFallback) {
return fetch(url, {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: payload.toString()
})
.then(r => r.json())
.then(data => {
if (data.success) {
Swal.fire({ icon: "success", title: successTitle, confirmButtonColor: "#3085d6" })
.then(() => location.reload());
} else {
Swal.fire({ icon: "error", title: "Errore", text: data.message || errorFallback });
}
})
.catch(err => {
Swal.fire({ icon: "error", title: "Errore", text: "Errore di comunicazione." });
console.error(err);
});
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
body: payload.toString()
})
.then(r => r.json())
.then(data => {
if (data.success) {
Swal.fire({
icon: "success",
title: successTitle,
confirmButtonColor: "#3085d6"
})
.then(() => location.reload());
} else {
Swal.fire({
icon: "error",
title: "Errore",
text: data.message || errorFallback
});
}
})
.catch(err => {
Swal.fire({
icon: "error",
title: "Errore",
text: "Errore di comunicazione."
});
console.error(err);
});
}
$("#addTopicForm").on("submit", function(e) {
@@ -527,4 +728,5 @@ $topics = $pdo->query($sql)->fetchAll(PDO::FETCH_ASSOC);
});
</script>
</body>
</html>
</html>
+400 -85
View File
@@ -23,7 +23,7 @@ $fEmployeeId = isset($_GET['employee_id']) && $_GET['employee_id'] !== '' ?
$fTopicId = isset($_GET['topic_id']) && $_GET['topic_id'] !== '' ? (int)$_GET['topic_id'] : 0;
$fStatus = isset($_GET['status']) ? trim($_GET['status']) : '';
$fType = isset($_GET['type']) ? trim($_GET['type']) : '';
$fDepartmentId = isset($_GET['department_id'])&& $_GET['department_id']!== '' ? (int)$_GET['department_id']: 0;
$fDepartmentId = isset($_GET['department_id']) && $_GET['department_id'] !== '' ? (int)$_GET['department_id'] : 0;
/* ==========================================
LOAD DATA
@@ -39,13 +39,22 @@ $where[] = "NOT EXISTS (
AND (et2.completed_date > et.completed_date
OR (et2.completed_date = et.completed_date AND et2.id > et.id))
)";
if ($fEmployeeId > 0) { $where[] = 'et.employee_id = :eid'; $params['eid'] = $fEmployeeId; }
if ($fTopicId > 0) { $where[] = 'et.training_topic_id = :tid'; $params['tid'] = $fTopicId; }
if ($fEmployeeId > 0) {
$where[] = 'et.employee_id = :eid';
$params['eid'] = $fEmployeeId;
}
if ($fTopicId > 0) {
$where[] = 'et.training_topic_id = :tid';
$params['tid'] = $fTopicId;
}
if ($fType !== '' && in_array($fType, ['initial', 'refresher'], true)) {
$where[] = 'et.training_type = :ty';
$params['ty'] = $fType;
}
if ($fDepartmentId > 0) { $where[] = 'e.department_id = :did'; $params['did'] = $fDepartmentId; }
if ($fDepartmentId > 0) {
$where[] = 'e.department_id = :did';
$params['did'] = $fDepartmentId;
}
$whereSql = $where ? ('WHERE ' . implode(' AND ', $where)) : '';
$stmt = $pdo->prepare("
@@ -66,7 +75,8 @@ $stmt->execute($params);
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
/* Filter by computed status */
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'];
}
@@ -83,9 +93,11 @@ function trainingStatus(?string $nextDue, ?int $reminderDays, ?int $topicDefault
$filtered = [];
$counters = ['compliant' => 0, 'due_soon' => 0, 'expired' => 0, 'not_present' => 0, 'all' => 0];
foreach ($rows as $r) {
$s = trainingStatus($r['next_due_date'] ?: null,
$s = trainingStatus(
$r['next_due_date'] ?: null,
$r['reminder_days'] !== null ? (int)$r['reminder_days'] : null,
$r['topic_default_rem'] !== null ? (int)$r['topic_default_rem'] : null);
$r['topic_default_rem'] !== null ? (int)$r['topic_default_rem'] : null
);
$r['_status'] = $s;
$counters['all']++;
$counters[$s['code']] = ($counters[$s['code']] ?? 0) + 1;
@@ -101,9 +113,18 @@ foreach ($rows as $r) {
if ($fType === '' || $fType === 'initial') {
$missingWhere = [];
$missingParams = [];
if ($fEmployeeId > 0) { $missingWhere[] = 'e.id = :eid'; $missingParams['eid'] = $fEmployeeId; }
if ($fTopicId > 0) { $missingWhere[] = 'tt.id = :tid'; $missingParams['tid'] = $fTopicId; }
if ($fDepartmentId > 0) { $missingWhere[] = 'e.department_id = :did'; $missingParams['did'] = $fDepartmentId; }
if ($fEmployeeId > 0) {
$missingWhere[] = 'e.id = :eid';
$missingParams['eid'] = $fEmployeeId;
}
if ($fTopicId > 0) {
$missingWhere[] = 'tt.id = :tid';
$missingParams['tid'] = $fTopicId;
}
if ($fDepartmentId > 0) {
$missingWhere[] = 'e.department_id = :did';
$missingParams['did'] = $fDepartmentId;
}
$missingWhereSql = $missingWhere ? ('AND ' . implode(' AND ', $missingWhere)) : '';
$missingStmt = $pdo->prepare("
@@ -163,7 +184,8 @@ $departments = $pdo->query("
SELECT id, name, color FROM departments WHERE is_active = 1 ORDER BY sort_order, name
")->fetchAll(PDO::FETCH_ASSOC);
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) : '—';
@@ -186,53 +208,266 @@ function fmtDate(?string $d): string {
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
<style>
body { font-size: 1.05rem; background: #f8fafc; }
.card { border-radius: 16px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); }
.back-dashboard {
background-color: #cfe3ff !important; color: #1f2d3d !important;
border: 1px solid #bcd4f4 !important; border-radius: 10px;
font-weight: 600; padding: 10px 18px;
body {
font-size: 1.05rem;
background: #f8fafc;
}
.stat-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 20px; }
@media (max-width: 991.98px) { .stat-row { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 575.98px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }
.stat-card {
border-radius: 14px; padding: 14px 16px; text-align: center;
background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.05);
cursor: pointer; transition: transform .15s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card.active { outline: 3px solid #0d6efd; }
.stat-card .stat-num { font-size: 1.8rem; font-weight: 700; line-height: 1; }
.stat-card .stat-label { font-size: 0.85rem; color: #64748b; margin-top: 4px; }
.stat-card.all .stat-num { color: #1f2937; }
.stat-card.compliant .stat-num { color: #16a34a; }
.stat-card.due_soon .stat-num { color: #d97706; }
.stat-card.expired .stat-num { color: #dc2626; }
.stat-card.not_present .stat-num { color: #6b7280; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.85rem; font-weight: 600; }
.pill-success { background: #d1fae5; color: #065f46; }
.pill-warning { background: #fef3c7; color: #92400e; }
.pill-danger { background: #fee2e2; color: #991b1b; }
.pill-secondary { background: #e5e7eb; color: #374151; }
.pill-role { background: #fff; color: #334155; border: 1px solid #cbd5e1; }
.pill-dept-inline { padding: 2px 8px; }
.card {
border-radius: 16px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
.back-dashboard {
background-color: #cfe3ff !important;
color: #1f2d3d !important;
border: 1px solid #bcd4f4 !important;
border-radius: 10px;
font-weight: 600;
padding: 10px 18px;
}
.training-header-actions {
display: flex;
align-items: center;
gap: 8px;
flex-wrap: wrap;
}
.btn-training-action {
border-radius: 10px;
font-weight: 500;
padding: 10px 16px;
box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
transition: all 0.2s ease-in-out;
color: #fff !important;
}
.btn-training-action:hover {
transform: translateY(-2px);
color: #fff !important;
}
.btn-training-topics {
background-color: #0d6efd !important;
border: 1px solid #0b5ed7 !important;
}
.btn-training-topics:hover {
background-color: #0b5ed7 !important;
}
.btn-training-calendar {
background-color: #2563eb !important;
border: 1px solid #1d4ed8 !important;
}
.btn-training-calendar:hover {
background-color: #1d4ed8 !important;
}
@media (max-width: 767.98px) {
.training-header-actions {
width: 100%;
flex-direction: column;
}
.training-header-actions .btn,
.training-header-actions a {
width: 100%;
}
}
.stat-row {
display: grid;
grid-template-columns: repeat(5, 1fr);
gap: 12px;
margin-bottom: 20px;
}
@media (max-width: 991.98px) {
.stat-row {
grid-template-columns: repeat(3, 1fr);
}
}
@media (max-width: 575.98px) {
.stat-row {
grid-template-columns: repeat(2, 1fr);
}
}
.stat-card {
border-radius: 14px;
padding: 14px 16px;
text-align: center;
background: #fff;
box-shadow: 0 2px 6px rgba(0, 0, 0, .05);
cursor: pointer;
transition: transform .15s, box-shadow .15s, border-color .15s;
border: 1px solid transparent;
text-decoration: none;
}
.stat-card:hover {
transform: translateY(-2px);
box-shadow: 0 6px 14px rgba(0, 0, 0, .10);
text-decoration: none;
}
.stat-card.active {
outline: 3px solid #0d6efd;
outline-offset: 2px;
}
.stat-card .stat-num {
font-size: 1.8rem;
font-weight: 800;
line-height: 1;
}
.stat-card .stat-label {
font-size: 0.85rem;
margin-top: 4px;
font-weight: 700;
}
/* Totale */
.stat-card.all {
background: #f8fafc;
border-color: #cbd5e1;
}
.stat-card.all .stat-num,
.stat-card.all .stat-label {
color: #1f2937;
}
/* Conforme - verde */
.stat-card.compliant {
background: #dcfce7;
border-color: #86efac;
}
.stat-card.compliant .stat-num,
.stat-card.compliant .stat-label {
color: #166534;
}
/* Da aggiornare - arancio */
.stat-card.due_soon {
background: #ffedd5;
border-color: #fdba74;
}
.stat-card.due_soon .stat-num,
.stat-card.due_soon .stat-label {
color: #9a3412;
}
/* Scaduti - rosso */
.stat-card.expired {
background: #fee2e2;
border-color: #fca5a5;
}
.stat-card.expired .stat-num,
.stat-card.expired .stat-label {
color: #991b1b;
}
/* Non presenti - rosso diverso / bordeaux */
.stat-card.not_present {
background: #fce7f3;
border-color: #f9a8d4;
}
.stat-card.not_present .stat-num,
.stat-card.not_present .stat-label {
color: #9d174d;
}
.pill {
display: inline-block;
padding: 3px 10px;
border-radius: 999px;
font-size: 0.85rem;
font-weight: 600;
}
.pill-success {
background: #d1fae5;
color: #065f46;
}
.pill-warning {
background: #fef3c7;
color: #92400e;
}
.pill-danger {
background: #fee2e2;
color: #991b1b;
}
.pill-secondary {
background: #e5e7eb;
color: #374151;
}
.pill-role {
background: #fff;
color: #334155;
border: 1px solid #cbd5e1;
}
.pill-dept-inline {
padding: 2px 8px;
}
.tr-card {
border: 1px solid #e2e8f0; border-radius: 14px;
padding: 14px 16px; margin-bottom: 12px;
border: 1px solid #e2e8f0;
border-radius: 14px;
padding: 14px 16px;
margin-bottom: 12px;
background: #fff;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}
.tr-card .name a { color: #1f2937; font-weight: 600; text-decoration: none; }
.tr-card .topic { color: #475569; }
.tr-card .meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.85rem; color: #64748b; margin-top: 8px; }
.tr-card .meta b { color: #1f2937; font-weight: 600; }
.tr-card .name a {
color: #1f2937;
font-weight: 600;
text-decoration: none;
}
.tr-card .topic {
color: #475569;
}
.tr-card .meta {
display: flex;
flex-wrap: wrap;
gap: 6px 14px;
font-size: 0.85rem;
color: #64748b;
margin-top: 8px;
}
.tr-card .meta b {
color: #1f2937;
font-weight: 600;
}
@media (max-width: 767.98px) {
.card-header { flex-direction: column; align-items: flex-start !important; gap: .5rem; }
.back-dashboard { width: 100%; }
.card-header {
flex-direction: column;
align-items: flex-start !important;
gap: .5rem;
}
.back-dashboard {
width: 100%;
}
}
</style>
</head>
@@ -246,11 +481,25 @@ function fmtDate(?string $d): string {
<div class="page-content">
<div class="card p-3">
<div class="card-header d-flex justify-content-between align-items-center flex-wrap gap-2">
<h5 class="mb-0">📚 Storico Formazione</h5>
<div class="d-flex gap-2 flex-wrap">
<h5 class="mb-0">📚 Gestione Formazione</h5>
<div class="training-header-actions">
<button type="button" class="btn btn-primary" id="btnBulkTraining">
Aggiungi sessione
</button>
<?php if (userCan('hr.training_topics.view')): ?>
<a href="training_topics.php" class="btn btn-training-action btn-training-topics">
📘 Corsi Formazione
</a>
<?php endif; ?>
<?php if (userCan('hr.trainings.view')): ?>
<a href="training_calendar.php" class="btn btn-training-action btn-training-calendar">
📅 Calendario Formazione
</a>
<?php endif; ?>
<button type="button" class="btn back-dashboard" onclick="location.href='production_dashboard.php'">
↩️ Torna alla Dashboard
</button>
@@ -323,7 +572,7 @@ function fmtDate(?string $d): string {
<label class="form-label small fw-semibold">Tipo</label>
<select name="type" class="form-select form-select-sm" onchange="this.form.submit()">
<option value=""> Tutti </option>
<option value="initial" <?= $fType === 'initial' ? 'selected' : '' ?>>Iniziale</option>
<option value="initial" <?= $fType === 'initial' ? 'selected' : '' ?>>Iniziale</option>
<option value="refresher" <?= $fType === 'refresher' ? 'selected' : '' ?>>Aggiornamento</option>
</select>
</div>
@@ -387,7 +636,7 @@ function fmtDate(?string $d): string {
<span class="pill pill-dept-inline" style="background:<?= htmlspecialchars($r['department_color'] ?? '#e5e7eb', ENT_QUOTES) ?>20; color:<?= htmlspecialchars($r['department_color'] ?? '#374151', ENT_QUOTES) ?>;">
<?= htmlspecialchars($r['department_name']) ?>
</span>
<?php else: ?>—<?php endif; ?>
<?php else: ?>—<?php endif; ?>
</td>
<td><?= htmlspecialchars($r['topic_name']) ?></td>
<td><span class="pill pill-role"><?= $typeLbl ?></span></td>
@@ -396,11 +645,11 @@ function fmtDate(?string $d): string {
<td><span class="pill pill-<?= $r['_status']['class'] ?>"><?= $r['_status']['label'] ?></span></td>
<td>
<?php if ($days === null): ?>
<?php elseif ($days < 0): ?>
<span class="text-danger fw-semibold"><?= $days ?></span>
<?php else: ?>
+<?= $days ?>
<?php endif; ?>
<?php elseif ($days < 0): ?>
<span class="text-danger fw-semibold"><?= $days ?></span>
<?php else: ?>
+<?= $days ?>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
@@ -514,7 +763,9 @@ function fmtDate(?string $d): string {
<textarea id="bulkDescription" class="form-control" rows="2"></textarea>
</div>
<div class="col-12"><hr class="my-1"></div>
<div class="col-12">
<hr class="my-1">
</div>
<div class="col-12">
<label class="form-label fw-semibold">Dipendenti <span class="text-danger">*</span></label>
@@ -600,7 +851,9 @@ function fmtDate(?string $d): string {
});
document.getElementById('bulkSelectAll').addEventListener('click', function() {
var all = $emp.find('option').map(function() { return this.value; }).get();
var all = $emp.find('option').map(function() {
return this.value;
}).get();
$emp.val(all).trigger('change');
});
document.getElementById('bulkClear').addEventListener('click', function() {
@@ -613,9 +866,18 @@ function fmtDate(?string $d): string {
var completed = document.getElementById('bulkCompletedDate').value;
var emps = $emp.val() || [];
if (!topicId) { Swal.fire('Attenzione', 'Selezionare un corso.', 'warning'); return; }
if (!completed) { Swal.fire('Attenzione', 'Indicare la data di completamento.', 'warning'); return; }
if (emps.length === 0) { Swal.fire('Attenzione', 'Selezionare almeno un dipendente.', 'warning'); return; }
if (!topicId) {
Swal.fire('Attenzione', 'Selezionare un corso.', 'warning');
return;
}
if (!completed) {
Swal.fire('Attenzione', 'Indicare la data di completamento.', 'warning');
return;
}
if (emps.length === 0) {
Swal.fire('Attenzione', 'Selezionare almeno un dipendente.', 'warning');
return;
}
var btn = document.getElementById('bulkSaveBtn');
btn.disabled = true;
@@ -630,22 +892,39 @@ function fmtDate(?string $d): string {
fd.append('description', document.getElementById('bulkDescription').value);
fd.append('update_frequency_months', document.getElementById('bulkFreq').value);
fd.append('reminder_days', document.getElementById('bulkRem').value);
emps.forEach(function(id) { fd.append('employee_ids[]', id); });
emps.forEach(function(id) {
fd.append('employee_ids[]', id);
});
fetch('ajax/trainings/save_bulk_training.php', { method: 'POST', body: fd })
.then(function(r) { return r.json(); })
fetch('ajax/trainings/save_bulk_training.php', {
method: 'POST',
body: fd
})
.then(function(r) {
return r.json();
})
.then(function(data) {
if (data.success) {
bulkModal.hide();
Swal.fire({ icon: 'success', title: 'Fatto', text: data.message, timer: 1800, showConfirmButton: false })
.then(function() { location.reload(); });
Swal.fire({
icon: 'success',
title: 'Fatto',
text: data.message,
timer: 1800,
showConfirmButton: false
})
.then(function() {
location.reload();
});
} else {
btn.disabled = false; btn.innerHTML = orig;
btn.disabled = false;
btn.innerHTML = orig;
Swal.fire('Errore', data.message || 'Errore.', 'error');
}
})
.catch(function() {
btn.disabled = false; btn.innerHTML = orig;
btn.disabled = false;
btn.innerHTML = orig;
Swal.fire('Errore', 'Errore di connessione.', 'error');
});
});
@@ -682,14 +961,22 @@ function fmtDate(?string $d): string {
function checkedIds() {
return Array.prototype.slice.call(document.querySelectorAll('.row-check:checked'))
.map(function(c) { return c.value; });
.map(function(c) {
return c.value;
});
}
function refreshBulkBar() {
var ids = checkedIds();
var bar = document.getElementById('bulkBar');
document.getElementById('bulkSelCount').textContent = ids.length;
if (ids.length > 0) { bar.classList.remove('d-none'); bar.classList.add('d-flex'); }
else { bar.classList.add('d-none'); bar.classList.remove('d-flex'); }
if (ids.length > 0) {
bar.classList.remove('d-none');
bar.classList.add('d-flex');
} else {
bar.classList.add('d-none');
bar.classList.remove('d-flex');
}
var all = document.querySelectorAll('.row-check');
if (checkAll) checkAll.checked = (all.length > 0 && ids.length === all.length);
}
@@ -698,11 +985,15 @@ function fmtDate(?string $d): string {
if (e.target && e.target.classList && e.target.classList.contains('row-check')) refreshBulkBar();
});
if (checkAll) checkAll.addEventListener('change', function() {
document.querySelectorAll('.row-check').forEach(function(c) { c.checked = checkAll.checked; });
document.querySelectorAll('.row-check').forEach(function(c) {
c.checked = checkAll.checked;
});
refreshBulkBar();
});
document.getElementById('btnBulkDeselect').addEventListener('click', function() {
document.querySelectorAll('.row-check').forEach(function(c) { c.checked = false; });
document.querySelectorAll('.row-check').forEach(function(c) {
c.checked = false;
});
if (checkAll) checkAll.checked = false;
refreshBulkBar();
});
@@ -718,8 +1009,14 @@ function fmtDate(?string $d): string {
e.preventDefault();
var ids = checkedIds();
var date = document.getElementById('renewDate').value;
if (ids.length === 0) { renewModal.hide(); return; }
if (!date) { Swal.fire('Attenzione', 'Indicare la data.', 'warning'); return; }
if (ids.length === 0) {
renewModal.hide();
return;
}
if (!date) {
Swal.fire('Attenzione', 'Indicare la data.', 'warning');
return;
}
var btn = document.getElementById('renewSaveBtn');
btn.disabled = true;
@@ -728,26 +1025,44 @@ function fmtDate(?string $d): string {
var fd = new FormData();
fd.append('completed_date', date);
ids.forEach(function(id) { fd.append('training_ids[]', id); });
ids.forEach(function(id) {
fd.append('training_ids[]', id);
});
fetch('ajax/trainings/bulk_update_deadline.php', { method: 'POST', body: fd })
.then(function(r) { return r.json(); })
fetch('ajax/trainings/bulk_update_deadline.php', {
method: 'POST',
body: fd
})
.then(function(r) {
return r.json();
})
.then(function(data) {
if (data.success) {
renewModal.hide();
Swal.fire({ icon: 'success', title: 'Fatto', text: data.message, timer: 1800, showConfirmButton: false })
.then(function() { location.reload(); });
Swal.fire({
icon: 'success',
title: 'Fatto',
text: data.message,
timer: 1800,
showConfirmButton: false
})
.then(function() {
location.reload();
});
} else {
btn.disabled = false; btn.innerHTML = orig;
btn.disabled = false;
btn.innerHTML = orig;
Swal.fire('Errore', data.message || 'Errore.', 'error');
}
})
.catch(function() {
btn.disabled = false; btn.innerHTML = orig;
btn.disabled = false;
btn.innerHTML = orig;
Swal.fire('Errore', 'Errore di connessione.', 'error');
});
});
});
</script>
</body>
</html>
</html>