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
+73 -12
View File
@@ -1448,10 +1448,13 @@ function fmtFileSize(?int $bytes): string
data-notes="<?= htmlspecialchars($p['notes'] ?? '', ENT_QUOTES) ?>">✏️</button>
<?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-name="<?= htmlspecialchars($p['ppe_name'], ENT_QUOTES) ?>">Rimuovi</button>
data-name="<?= htmlspecialchars($p['ppe_name'], ENT_QUOTES) ?>">Ritira</button>
<?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>
<?php endif; ?>
</tr>
@@ -1518,10 +1521,13 @@ function fmtFileSize(?int $bytes): string
data-notes="<?= htmlspecialchars($p['notes'] ?? '', ENT_QUOTES) ?>">✏️ Modifica</button>
<?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-name="<?= htmlspecialchars($p['ppe_name'], ENT_QUOTES) ?>">Rimuovi</button>
data-name="<?= htmlspecialchars($p['ppe_name'], ENT_QUOTES) ?>">Ritira</button>
<?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>
<?php endif; ?>
</div>
@@ -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: <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."
});
}
})