fixed scadenziario new field, dpi, dpi trash

This commit is contained in:
2026-07-16 12:05:37 +02:00
parent 1ef6cca149
commit 4e61426be7
8 changed files with 186 additions and 18 deletions
@@ -0,0 +1,24 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class AddVariazioniAndAttivaAlertToScadDeadlines extends AbstractMigration
{
public function change(): void
{
$this->table('scad_deadlines')
->addColumn('variazioni', 'text', [
'null' => true,
'default' => null,
'after' => 'notes'
])
->addColumn('attiva_alert', 'boolean', [
'null' => false,
'default' => false,
'after' => 'variazioni'
])
->update();
}
}
@@ -0,0 +1,44 @@
<?php
include('../../include/headscript.php');
header('Content-Type: application/json; charset=utf-8');
try {
$pdo = DBHandlerSelect::getInstance()->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;
}
+73 -12
View File
@@ -1448,10 +1448,13 @@ function fmtFileSize(?int $bytes): string
data-notes="<?= htmlspecialchars($p['notes'] ?? '', ENT_QUOTES) ?>">✏️</button> data-notes="<?= htmlspecialchars($p['notes'] ?? '', ENT_QUOTES) ?>">✏️</button>
<?php if (($p['status'] ?? '') === 'assigned'): ?> <?php if (($p['status'] ?? '') === 'assigned'): ?>
<button class="btn btn-sm btn-outline-danger delete-ppe" <button class="btn btn-sm btn-outline-warning withdraw-ppe"
data-id="<?= $pid ?>" data-id="<?= $pid ?>"
data-name="<?= htmlspecialchars($p['ppe_name'], ENT_QUOTES) ?>">Rimuovi</button> data-name="<?= htmlspecialchars($p['ppe_name'], ENT_QUOTES) ?>">Ritira</button>
<?php endif; ?> <?php endif; ?>
<button class="btn btn-sm btn-outline-danger destroy-ppe"
data-id="<?= $pid ?>"
data-name="<?= htmlspecialchars($p['ppe_name'], ENT_QUOTES) ?>" title="Elimina record">🗑️</button>
</td> </td>
<?php endif; ?> <?php endif; ?>
</tr> </tr>
@@ -1518,10 +1521,13 @@ function fmtFileSize(?int $bytes): string
data-notes="<?= htmlspecialchars($p['notes'] ?? '', ENT_QUOTES) ?>">✏️ Modifica</button> data-notes="<?= htmlspecialchars($p['notes'] ?? '', ENT_QUOTES) ?>">✏️ Modifica</button>
<?php if (($p['status'] ?? '') === 'assigned'): ?> <?php if (($p['status'] ?? '') === 'assigned'): ?>
<button class="btn btn-sm btn-outline-danger delete-ppe" <button class="btn btn-sm btn-outline-warning withdraw-ppe"
data-id="<?= $pid ?>" data-id="<?= $pid ?>"
data-name="<?= htmlspecialchars($p['ppe_name'], ENT_QUOTES) ?>">Rimuovi</button> data-name="<?= htmlspecialchars($p['ppe_name'], ENT_QUOTES) ?>">Ritira</button>
<?php endif; ?> <?php endif; ?>
<button class="btn btn-sm btn-outline-danger destroy-ppe"
data-id="<?= $pid ?>"
data-name="<?= htmlspecialchars($p['ppe_name'], ENT_QUOTES) ?>">🗑️ Elimina</button>
</div> </div>
<?php endif; ?> <?php endif; ?>
</div> </div>
@@ -3002,19 +3008,19 @@ function fmtFileSize(?int $bytes): string
}); });
}); });
// ---- PPE: remove / mark as returned ---- // ---- PPE: withdraw / mark as returned ----
$(document).on("click", ".delete-ppe", function() { $(document).on("click", ".withdraw-ppe", function() {
const id = $(this).data("id"); const id = $(this).data("id");
const name = $(this).data("name"); const name = $(this).data("name");
Swal.fire({ Swal.fire({
title: "Confermi la rimozione?", title: "Confermi il ritiro?",
text: name ? ("DPI: " + name) : "Il DPI verrà segnato come restituito.", text: name ? ("Il DPI \"" + name + "\" verrà ritirato dal dipendente.") : "Il DPI verrà ritirato dal dipendente.",
icon: "warning", icon: "warning",
showCancelButton: true, showCancelButton: true,
confirmButtonColor: "#d33", confirmButtonColor: "#e8930c",
cancelButtonColor: "#6c757d", cancelButtonColor: "#6c757d",
confirmButtonText: "Sì, rimuovi", confirmButtonText: "Sì, ritira",
cancelButtonText: "Annulla" cancelButtonText: "Annulla"
}).then((result) => { }).then((result) => {
if (!result.isConfirmed) return; if (!result.isConfirmed) return;
@@ -3034,7 +3040,7 @@ function fmtFileSize(?int $bytes): string
if (data.success) { if (data.success) {
Swal.fire({ Swal.fire({
icon: "success", icon: "success",
title: "Rimosso!", title: "Ritirato!",
confirmButtonColor: "#3085d6" confirmButtonColor: "#3085d6"
}) })
.then(() => location.reload()); .then(() => location.reload());
@@ -3042,7 +3048,62 @@ function fmtFileSize(?int $bytes): string
Swal.fire({ Swal.fire({
icon: "error", icon: "error",
title: "Errore", 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: <strong>" + name + "</strong><br>") : "") + "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."
}); });
} }
}) })
+32 -2
View File
@@ -563,6 +563,15 @@ $totalCategories = count($categories);
.ppe-name { .ppe-name {
font-weight: 800; font-weight: 800;
color: #0f172a; 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 { .ppe-description {
@@ -819,8 +828,13 @@ $totalCategories = count($categories);
</div> </div>
<?php if (!empty($ppe['description'])): ?> <?php if (!empty($ppe['description'])): ?>
<div class="ppe-description"> <div class="mt-1">
<?= htmlspecialchars($ppe['description'], ENT_QUOTES, 'UTF-8'); ?> <button type="button"
class="btn btn-sm btn-outline-secondary btn-desc-popup btnViewDescription"
data-ppe-name="<?= htmlspecialchars($ppe['name'], ENT_QUOTES, 'UTF-8'); ?>"
data-ppe-description="<?= htmlspecialchars($ppe['description'], ENT_QUOTES, 'UTF-8'); ?>">
📄 Descrizione
</button>
</div> </div>
<?php else: ?> <?php else: ?>
<div class="ppe-description"> <div class="ppe-description">
@@ -1391,7 +1405,23 @@ $totalCategories = count($categories);
}); });
}, 250); }, 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: `<div style="text-align:left; white-space:pre-wrap; color:#334155;">${htmlEscape(ppeDescription)}</div>`,
confirmButtonText: 'Chiudi',
confirmButtonColor: '#2563eb',
width: '600px'
});
});
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Photo preview | Photo preview
@@ -20,6 +20,7 @@ try {
$notification_days = isset($_POST['notification_days']) && is_numeric($_POST['notification_days']) ? (int)$_POST['notification_days'] : 7; $notification_days = isset($_POST['notification_days']) && is_numeric($_POST['notification_days']) ? (int)$_POST['notification_days'] : 7;
$storage_location = trim($_POST['storage_location'] ?? '') ?: null; $storage_location = trim($_POST['storage_location'] ?? '') ?: null;
$notes = trim($_POST['notes'] ?? '') ?: null; $notes = trim($_POST['notes'] ?? '') ?: null;
$variazioni = trim($_POST['variazioni'] ?? '') ?: null;
$employee_ids = $_POST['employee_ids'] ?? []; $employee_ids = $_POST['employee_ids'] ?? [];
$department_names = $_POST['department_names'] ?? []; $department_names = $_POST['department_names'] ?? [];
@@ -56,7 +57,7 @@ try {
UPDATE scad_deadlines SET UPDATE scad_deadlines SET
subject_id = ?, function_id = ?, notify_function = ?, topic = ?, law_regulation = ?, recurrence_type = ?, subject_id = ?, function_id = ?, notify_function = ?, topic = ?, law_regulation = ?, recurrence_type = ?,
due_date = ?, check_date = ?, document_date = ?, notification_days = ?, due_date = ?, check_date = ?, document_date = ?, notification_days = ?,
storage_location = ?, notes = ?, departments = ? storage_location = ?, notes = ?, variazioni = ?, departments = ?
WHERE id = ? WHERE id = ?
"); ");
$stmt->execute([ $stmt->execute([
@@ -72,6 +73,7 @@ try {
$notification_days, $notification_days,
$storage_location, $storage_location,
$notes, $notes,
$variazioni,
$departmentsStr, $departmentsStr,
$id $id
]); ]);
@@ -89,8 +91,8 @@ try {
$stmt = $pdo->prepare(" $stmt = $pdo->prepare("
INSERT INTO scad_deadlines INSERT INTO scad_deadlines
(subject_id, function_id, notify_function, topic, law_regulation, recurrence_type, due_date, check_date, (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) document_date, notification_days, storage_location, notes, variazioni, created_by, departments)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
"); ");
$stmt->execute([ $stmt->execute([
$subject_id, $subject_id,
@@ -105,6 +107,7 @@ try {
$notification_days, $notification_days,
$storage_location, $storage_location,
$notes, $notes,
$variazioni,
$currentUserId, $currentUserId,
$departmentsStr $departmentsStr
]); ]);
@@ -146,6 +146,10 @@
<label for="dlNotes" class="form-label fw-semibold">Note</label> <label for="dlNotes" class="form-label fw-semibold">Note</label>
<textarea class="form-control" id="dlNotes" name="notes" rows="3" placeholder="es. Scadenza 09/06/2026, Attività in appalto a Ditta specializzata..."></textarea> <textarea class="form-control" id="dlNotes" name="notes" rows="3" placeholder="es. Scadenza 09/06/2026, Attività in appalto a Ditta specializzata..."></textarea>
</div> </div>
<div class="col-12">
<label for="dlVariazioni" class="form-label fw-semibold">In caso di variazioni</label>
<textarea class="form-control" id="dlVariazioni" name="variazioni" rows="3" placeholder="es. In caso di variazioni normative, aggiornare la procedura..."></textarea>
</div>
</div> </div>
<!-- Group 5: Allegati --> <!-- Group 5: Allegati -->
@@ -155,7 +155,7 @@
$('#dlSubject').val(d.subject_id || '').trigger('change'); $('#dlSubject').val(d.subject_id || '').trigger('change');
document.getElementById('dlTopic').value = d.topic || ''; document.getElementById('dlTopic').value = d.topic || '';
$('#dlFunction').val(d.function_id || '').trigger('change'); $('#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('dlLaw').value = d.law_regulation || '';
document.getElementById('dlRecurrence').value = d.recurrence_type || 'once'; document.getElementById('dlRecurrence').value = d.recurrence_type || 'once';
fpDocDate.setDate(d.document_date || null, false, 'Y-m-d'); fpDocDate.setDate(d.document_date || null, false, 'Y-m-d');
@@ -164,6 +164,7 @@
document.getElementById('dlNotifDays').value = d.notification_days || 7; document.getElementById('dlNotifDays').value = d.notification_days || 7;
document.getElementById('dlStorage').value = d.storage_location || ''; document.getElementById('dlStorage').value = d.storage_location || '';
document.getElementById('dlNotes').value = d.notes || ''; document.getElementById('dlNotes').value = d.notes || '';
document.getElementById('dlVariazioni').value = d.variazioni || '';
document.getElementById('dlFiles').value = ''; document.getElementById('dlFiles').value = '';
document.getElementById('modalTitle').textContent = 'Modifica Scadenza'; document.getElementById('modalTitle').textContent = 'Modifica Scadenza';
$('#dlDepartments').val(d.department_names || []).trigger('change'); $('#dlDepartments').val(d.department_names || []).trigger('change');
+1
View File
@@ -941,6 +941,7 @@ function getContrastTextColor($hexColor)
<?php if ((int)$row['attachment_count'] > 0): ?> <?php if ((int)$row['attachment_count'] > 0): ?>
<span><i class="fa-solid fa-paperclip"></i> <?= (int)$row['attachment_count'] ?></span> <span><i class="fa-solid fa-paperclip"></i> <?= (int)$row['attachment_count'] ?></span>
<?php endif; ?> <?php endif; ?>
</div> </div>
<?php if (!$row['_isCompleted']): ?> <?php if (!$row['_isCompleted']): ?>
<div class="card-actions"> <div class="card-actions">