fixed export to lims, fixed multiple upload, added calendar to Data
This commit is contained in:
+46
-18
@@ -185,13 +185,21 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const file of files) {
|
||||
loader.style.display = "flex";
|
||||
console.log(`Inizio upload di ${files.length} file`);
|
||||
|
||||
let successCount = 0;
|
||||
let errorMessages = [];
|
||||
let uploadPromises = [];
|
||||
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
const file = files[i];
|
||||
if (!file.type.startsWith("image/")) {
|
||||
alert("Per favore, carica solo immagini!");
|
||||
alert(`File ${file.name} non è un'immagine, saltato!`);
|
||||
continue;
|
||||
}
|
||||
|
||||
loader.style.display = "flex";
|
||||
console.log(`Preparazione upload file ${i + 1}: ${file.name}`);
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("photo", file);
|
||||
@@ -201,23 +209,43 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
formData.append("iddatadb", iddatadb);
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch("upload_photo.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
const uploadPromise = fetch("upload_photo.php", {
|
||||
method: "POST",
|
||||
body: formData,
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then((result) => {
|
||||
if (result.success) {
|
||||
successCount++;
|
||||
console.log(`Successo per ${file.name}`);
|
||||
} else {
|
||||
errorMessages.push(
|
||||
`Errore per ${file.name}: ${result.message}`,
|
||||
);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
errorMessages.push(
|
||||
`Errore per ${file.name}: ${error.message}`,
|
||||
);
|
||||
});
|
||||
const result = await response.json();
|
||||
if (result.success) {
|
||||
loadPopupContent(iddatadb, idquotations);
|
||||
} else {
|
||||
alert("Errore durante il caricamento: " + result.message);
|
||||
}
|
||||
} catch (error) {
|
||||
alert("Errore durante il caricamento: " + error.message);
|
||||
} finally {
|
||||
loader.style.display = "none";
|
||||
}
|
||||
|
||||
uploadPromises.push(uploadPromise);
|
||||
}
|
||||
|
||||
await Promise.all(uploadPromises);
|
||||
|
||||
loader.style.display = "none";
|
||||
console.log(
|
||||
`Fine upload: ${successCount} riusciti, ${errorMessages.length} errori`,
|
||||
);
|
||||
|
||||
if (errorMessages.length > 0) {
|
||||
alert("Errori durante l'upload:\n" + errorMessages.join("\n"));
|
||||
}
|
||||
|
||||
// Ricarica sempre alla fine per aggiornare la lista, anche se parziale successo
|
||||
loadPopupContent(iddatadb, idquotations);
|
||||
}
|
||||
|
||||
function attachPhotoEventListeners(iddatadb, idquotations) {
|
||||
|
||||
Reference in New Issue
Block a user