add modifica record

This commit is contained in:
2026-04-28 11:56:31 +02:00
parent a1bcab3188
commit 1946648b1b
+28 -1
View File
@@ -1487,9 +1487,24 @@ function getContrastTextColor($hexColor)
}); });
}); });
// Edit // Edit with confirmation
$(document).on('click', '.btn-edit', function() { $(document).on('click', '.btn-edit', function() {
var id = $(this).closest('[data-id]').data('id'); var id = $(this).closest('[data-id]').data('id');
Swal.fire({
title: 'Vuoi modificare il record?',
text: 'Stai per aprire questo record in modifica.',
icon: 'question',
showCancelButton: true,
confirmButtonColor: '#5a8fd8',
cancelButtonText: 'Annulla',
confirmButtonText: 'Sì, modifica',
reverseButtons: true
}).then(function(result) {
if (!result.isConfirmed) {
return;
}
fetch('scadenzario/ajax/get_deadline.php?id=' + id) fetch('scadenzario/ajax/get_deadline.php?id=' + id)
.then(function(r) { .then(function(r) {
return r.json(); return r.json();
@@ -1499,7 +1514,9 @@ function getContrastTextColor($hexColor)
Swal.fire('Errore', data.message, 'error'); Swal.fire('Errore', data.message, 'error');
return; return;
} }
var d = data.data; var d = data.data;
document.getElementById('dlId').value = d.id; document.getElementById('dlId').value = d.id;
$('#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 || '';
@@ -1512,16 +1529,26 @@ function getContrastTextColor($hexColor)
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('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');
if (Array.isArray(d.employee_ids)) {
$('#dlEmployees').val(d.employee_ids.map(String)).trigger('change'); $('#dlEmployees').val(d.employee_ids.map(String)).trigger('change');
} else {
$('#dlEmployees').val(null).trigger('change');
}
renderAttachments(d.attachments || []); renderAttachments(d.attachments || []);
modal.show(); modal.show();
}) })
.catch(function() { .catch(function() {
Swal.fire('Errore', 'Errore di connessione.', 'error'); Swal.fire('Errore', 'Errore di connessione.', 'error');
}); });
}); });
});
// Complete // Complete
$(document).on('click', '.btn-complete', function() { $(document).on('click', '.btn-complete', function() {