fixed mescole delete deactivate
This commit is contained in:
+111
-22
@@ -158,8 +158,8 @@
|
||||
/* Azioni */
|
||||
#tabellaMescole th:nth-child(7),
|
||||
#tabellaMescole td:nth-child(7) {
|
||||
width: 190px;
|
||||
max-width: 190px;
|
||||
width: 230px;
|
||||
max-width: 230px;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
@@ -195,13 +195,13 @@
|
||||
.azioni-cell {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 6px;
|
||||
gap: 4px;
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
.azioni-cell .btn {
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
padding: 0;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
@@ -559,16 +559,25 @@
|
||||
|
||||
<button type='button' class='btn btn-sm {$toggleClass} toggle-active'
|
||||
data-id='{$row['id']}'
|
||||
data-active='" . ($isActive ? '1' : '0') . "'
|
||||
data-nomeuscita='" . htmlspecialchars($row['nomeuscita'] ?? '', ENT_QUOTES) . "'
|
||||
data-bs-toggle='tooltip' data-bs-placement='top' title='{$toggleText}'>
|
||||
🔁
|
||||
</button>
|
||||
|
||||
<button type='button' class='btn btn-sm btn-outline-secondary edit-mescola'
|
||||
data-id='{$row['id']}'
|
||||
data-nomeuscita='" . htmlspecialchars($row['nomeuscita'], ENT_QUOTES) . "'
|
||||
data-nomeuscita='" . htmlspecialchars($row['nomeuscita'] ?? '', ENT_QUOTES) . "'
|
||||
data-bs-toggle='tooltip' data-bs-placement='top' title='Modifica'>
|
||||
✏️
|
||||
</button>
|
||||
|
||||
<button type='button' class='btn btn-sm btn-outline-danger delete-mescola'
|
||||
data-id='{$row['id']}'
|
||||
data-nomeuscita='" . htmlspecialchars($row['nomeuscita'] ?? '', ENT_QUOTES) . "'
|
||||
data-bs-toggle='tooltip' data-bs-placement='top' title='Elimina'>
|
||||
🗑️
|
||||
</button>
|
||||
</td>
|
||||
</tr>";
|
||||
}
|
||||
@@ -837,30 +846,56 @@
|
||||
new bootstrap.Tooltip(el);
|
||||
});
|
||||
}
|
||||
|
||||
/* -------- TOGGLE ACTIVE -------- */
|
||||
$(document).on('click', '.toggle-active', function() {
|
||||
const id = $(this).data('id');
|
||||
const isActive = String($(this).data('active')) === '1';
|
||||
const nome = $(this).data('nomeuscita') || '';
|
||||
|
||||
fetch('toggle_mescola_active.php', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
body: `id=${encodeURIComponent(id)}`
|
||||
})
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
location.reload();
|
||||
} else {
|
||||
const azione = isActive ? 'Disattivare' : 'Attivare';
|
||||
const testo = isActive ?
|
||||
'La mescola non comparirà più nella lista delle attive.' :
|
||||
'La mescola tornerà disponibile fra le attive.';
|
||||
|
||||
Swal.fire({
|
||||
title: azione + ' la mescola?',
|
||||
html: (nome ? '<b>' + nome + '</b><br>' : '') + testo,
|
||||
icon: 'question',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'Sì, ' + (isActive ? 'disattiva' : 'attiva'),
|
||||
cancelButtonText: 'Annulla',
|
||||
confirmButtonColor: isActive ? '#e8930c' : '#16a34a',
|
||||
cancelButtonColor: '#6c757d'
|
||||
}).then((res) => {
|
||||
if (!res.isConfirmed) return;
|
||||
|
||||
fetch('toggle_mescola_active.php', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
body: `id=${encodeURIComponent(id)}`
|
||||
})
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
location.reload();
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "Errore",
|
||||
text: data.message || "Operazione non riuscita"
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(function() {
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "Errore",
|
||||
text: data.message || "Operazione non riuscita"
|
||||
text: "Errore di comunicazione."
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/* -------- AGGIUNTA MESCOLA -------- */
|
||||
@@ -938,6 +973,60 @@
|
||||
});
|
||||
});
|
||||
|
||||
/* -------- CANCELLAZIONE MESCOLA -------- */
|
||||
$(document).on("click", ".delete-mescola", function() {
|
||||
const id = $(this).data("id");
|
||||
const nome = $(this).data("nomeuscita") || '';
|
||||
|
||||
Swal.fire({
|
||||
title: "Eliminare definitivamente?",
|
||||
html: (nome ? '<b>' + nome + '</b><br>' : '') +
|
||||
"L'operazione non può essere annullata.<br>" +
|
||||
"<span class='text-muted small'>Se la mescola ha lotti o file, disattivala invece di eliminarla.</span>",
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonText: "Sì, elimina",
|
||||
cancelButtonText: "Annulla",
|
||||
confirmButtonColor: "#d33",
|
||||
cancelButtonColor: "#6c757d"
|
||||
}).then((res) => {
|
||||
if (!res.isConfirmed) return;
|
||||
|
||||
fetch("delete_mescola.php", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded"
|
||||
},
|
||||
body: `id=${encodeURIComponent(id)}`
|
||||
})
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
Swal.fire({
|
||||
icon: "success",
|
||||
title: "Eliminata!",
|
||||
timer: 1400,
|
||||
showConfirmButton: false
|
||||
})
|
||||
.then(() => location.reload());
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "Impossibile eliminare",
|
||||
text: data.message || "Operazione non riuscita"
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(function() {
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "Errore",
|
||||
text: "Errore di comunicazione."
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/* -------- MODALE ASSOCIA LINEE -------- */
|
||||
$(document).on("click", ".associa-linee", function() {
|
||||
const idMescola = $(this).data("id");
|
||||
|
||||
Reference in New Issue
Block a user