560560 function controllaMagazzino() {
561561 if(!abilita_scorte) return;
562562
563- let righe = $("#righe_documento_importato tr");
563+ let righe = $("#righe_documento_importato tr", "#modals" );
564564
565565 // Lettura delle righe selezionate per l \'improtazione
566566 let richieste = {};
567567 for(const r of righe) {
568568 let riga = $(r);
569569 let id = $(riga).data("local_id");
570- let id_articolo = riga.find("[id^=id_articolo_]").text();
570+ let id_articolo = riga.find("#modals [id^=id_articolo_]").text();
571571
572- if (!$("#checked_" + id).is(":checked") || !id_articolo) {
572+ if (!$("#checked_" + id, "#modals" ).is(":checked") || !id_articolo) {
573573 continue;
574574 }
575575
576- let qta = parseFloat(riga.find("input[id^=qta_]").val());
576+ let qta = parseFloat(riga.find("#modals input[id^=qta_]").val());
577577 richieste[id_articolo] = richieste[id_articolo] ? richieste[id_articolo] + qta : qta;
578578 }
579579
580- let sottoscorta = $("#articoli_sottoscorta");
580+ let sottoscorta = $("#modals # articoli_sottoscorta");
581581 let body = sottoscorta.find("tbody");
582582 body.html("");
583583
@@ -601,15 +601,15 @@ function controllaMagazzino() {
601601 }
602602 }
603603
604- $("input[name=righe]").each(function() {
604+ $("#modals input[name=righe]").each(function() {
605605 ricalcolaTotaleRiga($(this).val(), first = true);
606606 });
607607
608608 function ricalcolaTotaleRiga(r, first) {
609- let prezzo_unitario = $("#prezzo_unitario_" + r).val();
610- let sconto = $("#sconto_unitario_" + r).val();
609+ let prezzo_unitario = $("#modals # prezzo_unitario_" + r).val();
610+ let sconto = $("#modals # sconto_unitario_" + r).val();
611611
612- let max_qta_input = $("#max_qta_" + r);
612+ let max_qta_input = $("#modals # max_qta_" + r);
613613 let qta_max = max_qta_input.val();
614614
615615 prezzo_unitario = parseFloat(prezzo_unitario);
@@ -618,30 +618,30 @@ function ricalcolaTotaleRiga(r, first) {
618618
619619 let prezzo_scontato = prezzo_unitario - sconto;
620620
621- let qta = ($("#qta_" + r).val()).toEnglish();
621+ let qta = ($("#modals # qta_" + r).val()).toEnglish();
622622
623623 // Se inserisco una quantità da evadere maggiore di quella rimanente, la imposto al massimo possibile
624624 if (qta > qta_max) {
625625 qta = qta_max;
626626
627- $("#qta_" + r).val(qta);
627+ $("#modals # qta_" + r).val(qta);
628628 }
629629
630630 // Se tolgo la spunta della casella dell \'evasione devo azzerare i conteggi
631- if (isNaN(qta) || !$("#checked_" + r).is(":checked")) {
631+ if (isNaN(qta) || !$("#modals # checked_" + r).is(":checked")) {
632632 qta = 0;
633633 }
634634
635635 if (!first) {
636- let serial_select = $("#serial_" + r);
636+ let serial_select = $("#modals # serial_" + r);
637637 serial_select.selectClear();
638638 serial_select.data("maximum", qta);
639- initSelectInput("#serial_" + r);
639+ initSelectInput("#modals # serial_" + r);
640640 }
641641
642642 let subtotale = (prezzo_scontato * qta).toLocale();
643643
644- $("#subtotale_" + r).html(subtotale + " " + globals.currency);
644+ $("#modals # subtotale_" + r).html(subtotale + " " + globals.currency);
645645
646646
647647 ricalcolaTotale();
@@ -651,16 +651,16 @@ function ricalcolaTotale() {
651651 let totale = 0.00;
652652 let totale_qta = 0;
653653
654- $("input[id*=qta_]").each(function() {
654+ $("#modals input[id*=qta_]").each(function() {
655655 let qta = $(this).val().toEnglish();
656656 let r = $(this).attr("id").replace("qta_", "");
657657
658- if (!$("#checked_" + r).is(":checked") || isNaN(qta)) {
658+ if (!$("#modals # checked_" + r).is(":checked") || isNaN(qta)) {
659659 qta = 0;
660660 }
661661
662- let prezzo_unitario = $("#prezzo_unitario_" + r).val();
663- let sconto = $("#sconto_unitario_" + r).val();
662+ let prezzo_unitario = $("#modals # prezzo_unitario_" + r).val();
663+ let sconto = $("#modals # sconto_unitario_" + r).val();
664664
665665 prezzo_unitario = parseFloat(prezzo_unitario);
666666 sconto = parseFloat(sconto);
@@ -674,31 +674,31 @@ function ricalcolaTotale() {
674674 totale_qta += qta;
675675 });
676676
677- $("#totale").html((totale.toLocale()) + " " + globals.currency);
677+ $("#modals # totale").html((totale.toLocale()) + " " + globals.currency);
678678
679679 controllaMagazzino();
680680 }
681681
682682 $(document).ready(function(){
683683 if(input("id_ritenuta_acconto").get()) {
684- $("#calcolo_ritenuta_acconto").prop("required", true);
684+ $("#modals # calcolo_ritenuta_acconto").prop("required", true);
685685 } else{
686- $("#calcolo_ritenuta_acconto").prop("required", false);
686+ $("#modals # calcolo_ritenuta_acconto").prop("required", false);
687687 input("calcolo_ritenuta_acconto").set("");
688688 }
689689
690- $("#id_ritenuta_acconto").on("change", function(){
690+ $("#modals # id_ritenuta_acconto").on("change", function(){
691691 if(input("id_ritenuta_acconto").get()) {
692- $("#calcolo_ritenuta_acconto").prop("required", true);
692+ $("#modals # calcolo_ritenuta_acconto").prop("required", true);
693693 } else{
694- $("#calcolo_ritenuta_acconto").prop("required", false);
694+ $("#modals # calcolo_ritenuta_acconto").prop("required", false);
695695 input("calcolo_ritenuta_acconto").set("");
696696 }
697697 });
698698 ricalcolaTotale();
699699 });
700700
701- $("#import_all").click(function(){
701+ $("#modals # import_all").click(function(){
702702 if( $(this).is(":checked") ){
703703 $(".check").each(function(){
704704 if( !$(this).is(":checked") ){
0 commit comments