diff --git a/db/migrations/20260716093425_add_variazioni_and_attiva_alert_to_scad_deadlines.php b/db/migrations/20260716093425_add_variazioni_and_attiva_alert_to_scad_deadlines.php new file mode 100644 index 0000000..b921e1a --- /dev/null +++ b/db/migrations/20260716093425_add_variazioni_and_attiva_alert_to_scad_deadlines.php @@ -0,0 +1,24 @@ +table('scad_deadlines') + ->addColumn('variazioni', 'text', [ + 'null' => true, + 'default' => null, + 'after' => 'notes' + ]) + ->addColumn('attiva_alert', 'boolean', [ + 'null' => false, + 'default' => false, + 'after' => 'variazioni' + ]) + ->update(); + } +} diff --git a/public/userarea/ajax/employee_profile/destroy_ppe.php b/public/userarea/ajax/employee_profile/destroy_ppe.php new file mode 100644 index 0000000..9ac849f --- /dev/null +++ b/public/userarea/ajax/employee_profile/destroy_ppe.php @@ -0,0 +1,44 @@ +getConnection(); + + $id = (int)($_POST['id'] ?? 0); + + if ($id <= 0) { + echo json_encode([ + 'success' => false, + 'message' => 'ID DPI non valido.' + ]); + exit; + } + + $stmt = $pdo->prepare(" + DELETE FROM employee_ppe_items + WHERE id = ? + "); + $stmt->execute([$id]); + + if ($stmt->rowCount() === 0) { + echo json_encode([ + 'success' => false, + 'message' => 'Record non trovato o già eliminato.' + ]); + exit; + } + + echo json_encode([ + 'success' => true, + 'message' => 'Record DPI eliminato definitivamente.' + ]); + exit; +} catch (Throwable $e) { + echo json_encode([ + 'success' => false, + 'message' => $e->getMessage() + ]); + exit; +} diff --git a/public/userarea/employee-profile.php b/public/userarea/employee-profile.php index f980a43..2c7abe0 100644 --- a/public/userarea/employee-profile.php +++ b/public/userarea/employee-profile.php @@ -1448,10 +1448,13 @@ function fmtFileSize(?int $bytes): string data-notes="">✏️ - + data-name="">Ritira + @@ -1518,10 +1521,13 @@ function fmtFileSize(?int $bytes): string data-notes="">✏️ Modifica - + data-name="">Ritira + @@ -3002,19 +3008,19 @@ function fmtFileSize(?int $bytes): string }); }); - // ---- PPE: remove / mark as returned ---- - $(document).on("click", ".delete-ppe", function() { + // ---- PPE: withdraw / mark as returned ---- + $(document).on("click", ".withdraw-ppe", function() { const id = $(this).data("id"); const name = $(this).data("name"); Swal.fire({ - title: "Confermi la rimozione?", - text: name ? ("DPI: " + name) : "Il DPI verrà segnato come restituito.", + title: "Confermi il ritiro?", + text: name ? ("Il DPI \"" + name + "\" verrà ritirato dal dipendente.") : "Il DPI verrà ritirato dal dipendente.", icon: "warning", showCancelButton: true, - confirmButtonColor: "#d33", + confirmButtonColor: "#e8930c", cancelButtonColor: "#6c757d", - confirmButtonText: "Sì, rimuovi", + confirmButtonText: "Sì, ritira", cancelButtonText: "Annulla" }).then((result) => { if (!result.isConfirmed) return; @@ -3034,7 +3040,7 @@ function fmtFileSize(?int $bytes): string if (data.success) { Swal.fire({ icon: "success", - title: "Rimosso!", + title: "Ritirato!", confirmButtonColor: "#3085d6" }) .then(() => location.reload()); @@ -3042,7 +3048,62 @@ function fmtFileSize(?int $bytes): string Swal.fire({ icon: "error", title: "Errore", - text: data.message || "Impossibile rimuovere." + text: data.message || "Impossibile ritirare." + }); + } + }) + .catch(err => { + Swal.fire({ + icon: "error", + title: "Errore", + text: "Errore di comunicazione." + }); + console.error(err); + }); + }); + }); + + // ---- PPE: destroy record (hard delete) ---- + $(document).on("click", ".destroy-ppe", function() { + const id = $(this).data("id"); + const name = $(this).data("name"); + + Swal.fire({ + title: "Eliminare definitivamente il record?", + html: (name ? ("DPI: " + name + "
") : "") + "Questa azione elimina il record e non può essere annullata. Usala solo in caso di inserimento errato.", + icon: "warning", + showCancelButton: true, + confirmButtonColor: "#d33", + cancelButtonColor: "#6c757d", + confirmButtonText: "Sì, elimina", + cancelButtonText: "Annulla" + }).then((result) => { + if (!result.isConfirmed) return; + + const p = new URLSearchParams(); + p.append('id', id); + + fetch("ajax/employee_profile/destroy_ppe.php", { + method: "POST", + headers: { + "Content-Type": "application/x-www-form-urlencoded" + }, + body: p.toString() + }) + .then(r => r.json()) + .then(data => { + if (data.success) { + Swal.fire({ + icon: "success", + title: "Eliminato!", + confirmButtonColor: "#3085d6" + }) + .then(() => location.reload()); + } else { + Swal.fire({ + icon: "error", + title: "Errore", + text: data.message || "Impossibile eliminare." }); } }) diff --git a/public/userarea/ppe-items.php b/public/userarea/ppe-items.php index 37f61f2..ec13402 100644 --- a/public/userarea/ppe-items.php +++ b/public/userarea/ppe-items.php @@ -563,6 +563,15 @@ $totalCategories = count($categories); .ppe-name { font-weight: 800; color: #0f172a; + white-space: normal; + word-break: break-word; + } + + .btn-desc-popup { + border-radius: 8px; + font-weight: 700; + font-size: 0.78rem; + padding: 2px 8px; } .ppe-description { @@ -819,8 +828,13 @@ $totalCategories = count($categories); -
- +
+
@@ -1391,7 +1405,23 @@ $totalCategories = count($categories); }); }, 250); }); + /* + |-------------------------------------------------------------------------- + | View description popup + |-------------------------------------------------------------------------- + */ + $(document).on('click', '.btnViewDescription', function() { + const ppeName = $(this).data('ppe-name'); + const ppeDescription = $(this).data('ppe-description'); + Swal.fire({ + title: htmlEscape(ppeName), + html: `
${htmlEscape(ppeDescription)}
`, + confirmButtonText: 'Chiudi', + confirmButtonColor: '#2563eb', + width: '600px' + }); + }); /* |-------------------------------------------------------------------------- | Photo preview diff --git a/public/userarea/scadenzario/ajax/save_deadline.php b/public/userarea/scadenzario/ajax/save_deadline.php index 60f162e..4495e36 100644 --- a/public/userarea/scadenzario/ajax/save_deadline.php +++ b/public/userarea/scadenzario/ajax/save_deadline.php @@ -20,6 +20,7 @@ try { $notification_days = isset($_POST['notification_days']) && is_numeric($_POST['notification_days']) ? (int)$_POST['notification_days'] : 7; $storage_location = trim($_POST['storage_location'] ?? '') ?: null; $notes = trim($_POST['notes'] ?? '') ?: null; + $variazioni = trim($_POST['variazioni'] ?? '') ?: null; $employee_ids = $_POST['employee_ids'] ?? []; $department_names = $_POST['department_names'] ?? []; @@ -56,7 +57,7 @@ try { UPDATE scad_deadlines SET subject_id = ?, function_id = ?, notify_function = ?, topic = ?, law_regulation = ?, recurrence_type = ?, due_date = ?, check_date = ?, document_date = ?, notification_days = ?, - storage_location = ?, notes = ?, departments = ? + storage_location = ?, notes = ?, variazioni = ?, departments = ? WHERE id = ? "); $stmt->execute([ @@ -72,6 +73,7 @@ try { $notification_days, $storage_location, $notes, + $variazioni, $departmentsStr, $id ]); @@ -89,8 +91,8 @@ try { $stmt = $pdo->prepare(" INSERT INTO scad_deadlines (subject_id, function_id, notify_function, topic, law_regulation, recurrence_type, due_date, check_date, - document_date, notification_days, storage_location, notes, created_by, departments) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) + document_date, notification_days, storage_location, notes, variazioni, created_by, departments) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) "); $stmt->execute([ $subject_id, @@ -105,6 +107,7 @@ try { $notification_days, $storage_location, $notes, + $variazioni, $currentUserId, $departmentsStr ]); diff --git a/public/userarea/scadenzario/include/deadline_modal.php b/public/userarea/scadenzario/include/deadline_modal.php index 826d071..2ddb12c 100644 --- a/public/userarea/scadenzario/include/deadline_modal.php +++ b/public/userarea/scadenzario/include/deadline_modal.php @@ -146,6 +146,10 @@
+
+ + +
diff --git a/public/userarea/scadenzario/include/deadline_modal_js.php b/public/userarea/scadenzario/include/deadline_modal_js.php index 8e24019..bb6ee65 100644 --- a/public/userarea/scadenzario/include/deadline_modal_js.php +++ b/public/userarea/scadenzario/include/deadline_modal_js.php @@ -155,7 +155,7 @@ $('#dlSubject').val(d.subject_id || '').trigger('change'); document.getElementById('dlTopic').value = d.topic || ''; $('#dlFunction').val(d.function_id || '').trigger('change'); - $('#notify_function').prop('checked', Number(d.notify_function) === 1); + $('#notify_function').prop('checked', Number(d.notify_function) === 1); document.getElementById('dlLaw').value = d.law_regulation || ''; document.getElementById('dlRecurrence').value = d.recurrence_type || 'once'; fpDocDate.setDate(d.document_date || null, false, 'Y-m-d'); @@ -164,6 +164,7 @@ document.getElementById('dlNotifDays').value = d.notification_days || 7; document.getElementById('dlStorage').value = d.storage_location || ''; document.getElementById('dlNotes').value = d.notes || ''; + document.getElementById('dlVariazioni').value = d.variazioni || ''; document.getElementById('dlFiles').value = ''; document.getElementById('modalTitle').textContent = 'Modifica Scadenza'; $('#dlDepartments').val(d.department_names || []).trigger('change'); diff --git a/public/userarea/scadenzario/index.php b/public/userarea/scadenzario/index.php index 607adeb..9ea5d73 100644 --- a/public/userarea/scadenzario/index.php +++ b/public/userarea/scadenzario/index.php @@ -941,6 +941,7 @@ function getContrastTextColor($hexColor) 0): ?> +