fixed matrici with db cron
This commit is contained in:
@@ -1183,9 +1183,13 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
</script>
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
// Lazy loading per il modal delle parti
|
||||
$(document).on('click', '.parts-btn', function() {
|
||||
const iddatadb = $(this).data('iddatadb');
|
||||
const iddatadb = $(this).data('iddatadb') || null;
|
||||
const idquotations = $(this).data('idquotations') || null;
|
||||
const rowIndex = $(this).data('row');
|
||||
const importRef = $("table tbody tr").eq(rowIndex).find("td").eq(1).text();
|
||||
const description = $("table tbody tr").eq(rowIndex).find("td").eq(2).text() || "Sconosciuto";
|
||||
|
||||
$.ajax({
|
||||
url: 'modal_parts.php',
|
||||
method: 'GET',
|
||||
@@ -1193,25 +1197,65 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
iddatadb: iddatadb
|
||||
},
|
||||
success: function(response) {
|
||||
// Inserisci il modale nel container
|
||||
$('#partsModalContainer').html(response);
|
||||
$('#partsModal').modal('show');
|
||||
// Carica i dati delle parti, se necessario
|
||||
if (typeof loadParts === 'function') {
|
||||
loadParts(iddatadb);
|
||||
|
||||
// Verifica che il modale esista
|
||||
const modalElement = document.getElementById('partsModal');
|
||||
if (!modalElement) {
|
||||
console.error('Elemento modale non trovato: #partsModal');
|
||||
const errorMsg = $('<div class="alert alert-danger temp-alert" role="alert">Errore: Modale non trovato.</div>');
|
||||
$("body").prepend(errorMsg);
|
||||
setTimeout(() => errorMsg.fadeOut(500, function() {
|
||||
$(this).remove();
|
||||
}), 5000);
|
||||
return;
|
||||
}
|
||||
|
||||
// Imposta i dati del modale
|
||||
$("#trfHeader").text(`${iddatadb || idquotations} - ${importRef} - ${description}`);
|
||||
$("#partsModal").data("iddatadb", iddatadb).data("idquotations", idquotations);
|
||||
|
||||
// Inizializza il modale con l'API nativa di Bootstrap
|
||||
let modal = bootstrap.Modal.getInstance(modalElement);
|
||||
if (!modal) {
|
||||
modal = new bootstrap.Modal(modalElement, {
|
||||
backdrop: true,
|
||||
keyboard: true,
|
||||
focus: true
|
||||
});
|
||||
}
|
||||
modal.show();
|
||||
|
||||
// Carica i dati delle parti e delle foto
|
||||
if (typeof loadParts === 'function') {
|
||||
loadParts(iddatadb, idquotations);
|
||||
}
|
||||
// Gestisci il backdrop
|
||||
$('.modal-backdrop').remove(); // Rimuovi backdrop precedenti
|
||||
$('body').addClass('modal-open').append('<div class="modal-backdrop fade show"></div>');
|
||||
},
|
||||
error: function() {
|
||||
alert('Errore nel caricamento del modal delle parti.');
|
||||
error: function(xhr, status, error) {
|
||||
console.error('Errore nel caricamento del modale:', error);
|
||||
const errorMsg = $('<div class="alert alert-danger temp-alert" role="alert">Errore nel caricamento del modale: ' + error + '</div>');
|
||||
$("body").prepend(errorMsg);
|
||||
setTimeout(() => errorMsg.fadeOut(500, function() {
|
||||
$(this).remove();
|
||||
}), 5000);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Pulizia del DOM quando il modal delle parti viene chiuso
|
||||
// Pulizia completa alla chiusura del modale
|
||||
$(document).on('hidden.bs.modal', '#partsModal', function() {
|
||||
const modalElement = document.getElementById('partsModal');
|
||||
if (modalElement) {
|
||||
const modal = bootstrap.Modal.getInstance(modalElement);
|
||||
if (modal) {
|
||||
modal.dispose();
|
||||
}
|
||||
}
|
||||
$('#partsModalContainer').empty();
|
||||
$('.modal-backdrop').remove();
|
||||
$('body').removeClass('modal-open').css('padding-right', '');
|
||||
$('.overlay.toggle-icon').css('display', 'none');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user