You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
html: "'.tr('Verranno scaricate tutte le fatture da importare, e non sarà più possibile visualizzare altre informazioni oltre al nome per le fatture che non verranno importate completamente. Continuare?').'",
269
-
showCancelButton: true,
270
-
confirmButtonText: "'.tr('Procedi').'",
271
-
type: "info",
272
-
}).then(function (result) {
273
-
var restore = buttonLoading(btn);
274
-
$("#main_loading").show();
275
-
276
-
$.ajax({
277
-
url: globals.rootdir + "/actions.php",
278
-
data: {
279
-
op: "list",
280
-
id_module: "'.$id_module.'",
281
-
id_plugin: "'.$id_plugin.'",
282
-
},
283
-
type: "post",
284
-
success: function(data){
285
-
try {
286
-
// Verifica se la risposta è vuota
287
-
if (!data || data.trim() === "") {
288
-
console.error("Risposta vuota dal server");
289
-
swal("'.tr('Errore').'", "'.tr('Risposta vuota dal server').'", "error");
290
-
buttonRestore(btn, restore);
291
-
$("#main_loading").fadeOut();
292
-
return;
293
-
}
294
-
295
-
data = JSON.parse(data);
296
-
} catch (e) {
297
-
console.error("Errore parsing JSON:", e);
298
-
console.error("Dati ricevuti:", data);
299
-
swal("'.tr('Errore').'", "'.tr('Errore durante l\'elaborazione della risposta del server').'", "error");
265
+
// Controlla se ci sono fatture caricate nella datatable
266
+
var invoiceRows = $("table tbody tr:not(#no-results-message)").length;
267
+
268
+
if (invoiceRows === 0) {
269
+
swal({
270
+
title: "'.tr('Nessuna fattura da importare').'",
271
+
type: "info",
272
+
});
273
+
return;
274
+
}
275
+
276
+
var restore = buttonLoading(btn);
277
+
$("#main_loading").show();
278
+
279
+
// Prima verifica se ci sono documenti da importare
280
+
$.ajax({
281
+
url: globals.rootdir + "/actions.php",
282
+
data: {
283
+
op: "list",
284
+
id_module: "'.$id_module.'",
285
+
id_plugin: "'.$id_plugin.'",
286
+
},
287
+
type: "post",
288
+
success: function(data){
289
+
try {
290
+
// Verifica se la risposta è vuota
291
+
if (!data || data.trim() === "") {
292
+
console.error("Risposta vuota dal server");
293
+
swal("'.tr('Errore').'", "'.tr('Risposta vuota dal server').'", "error");
300
294
buttonRestore(btn, restore);
301
295
$("#main_loading").fadeOut();
302
296
return;
303
297
}
304
298
299
+
data = JSON.parse(data);
300
+
} catch (e) {
301
+
console.error("Errore parsing JSON:", e);
302
+
console.error("Dati ricevuti:", data);
303
+
swal("'.tr('Errore').'", "'.tr('Errore durante l\'elaborazione della risposta del server').'", "error");
304
+
buttonRestore(btn, restore);
305
+
$("#main_loading").fadeOut();
306
+
return;
307
+
}
308
+
309
+
// Controlla se ci sono documenti da importare
310
+
if (!data || data.length === 0) {
311
+
swal({
312
+
title: "'.tr('Nessuna fattura da importare').'",
313
+
type: "info",
314
+
});
315
+
buttonRestore(btn, restore);
316
+
$("#main_loading").fadeOut();
317
+
return;
318
+
}
319
+
320
+
// Se ci sono documenti, mostra il dialogo di conferma
321
+
swal({
322
+
title: "'.tr('Importare tutte le fatture?').'",
323
+
html: "'.tr('Verranno scaricate tutte le fatture da importare, e non sarà più possibile visualizzare altre informazioni oltre al nome per le fatture che non verranno importate completamente. Continuare?').'",
324
+
showCancelButton: true,
325
+
confirmButtonText: "'.tr('Procedi').'",
326
+
type: "info",
327
+
}).then(function (result) {
305
328
count = data.length;
306
329
counter = 0;
307
330
data.forEach(function(element) {
@@ -328,14 +351,14 @@ function importAllZip(btn) {
328
351
});
329
352
330
353
importComplete(count, counter, btn, restore);
331
-
},
332
-
error: function(data) {
333
-
alert("'.tr('Errore').': " + data);
354
+
});
355
+
},
356
+
error: function(data) {
357
+
alert("'.tr('Errore').': " + data);
334
358
335
-
$("#main_loading").fadeOut();
336
-
buttonRestore(btn, restore);
337
-
}
338
-
});
359
+
$("#main_loading").fadeOut();
360
+
buttonRestore(btn, restore);
361
+
}
339
362
});
340
363
}
341
364
@@ -347,12 +370,6 @@ function importComplete(count, counter, btn, restore) {
0 commit comments