diff --git a/modules/contratti/edit.php b/modules/contratti/edit.php index 344f87c3c..4c4d6aad7 100755 --- a/modules/contratti/edit.php +++ b/modules/contratti/edit.php @@ -327,30 +327,52 @@ if (!empty($rs)) {
'; if (!$block_edit) { + // Form di inserimento riga documento echo ' - '; + '; } echo ' @@ -389,8 +411,7 @@ async function gestioneRiga(button, options) { await salvaForm("#edit-form", {}, button); // Lettura titolo e chiusura tooltip - let title = $(button).tooltipster("content"); - $(button).tooltipster("close") + let title = $(button).attr("data-title"); // Apertura modal options = options ? options : "is_riga"; @@ -400,21 +421,22 @@ async function gestioneRiga(button, options) { /** * Funzione dedicata al caricamento dinamico via AJAX delle righe del documento. */ -function caricaRighe() { +function caricaRighe(id_riga) { let container = $("#righe"); localLoading(container, true); return $.get("'.$structure->fileurl('row-list.php').'?id_module='.$id_module.'&id_record='.$id_record.'", function(data) { container.html(data); localLoading(container, false); + if (id_riga != null) { + $("tr[data-id="+ id_riga +"]").effect("highlight",1000); + } }); } $(document).ready(function() { - caricaRighe(); -}); - -$(document).ready(function() { + caricaRighe(null); + $("#data_accettazione").on("dp.change", function() { if($(this).val()){ $("#data_rifiuto").attr("disabled", true); @@ -433,6 +455,28 @@ $(document).ready(function() { $("#data_accettazione").trigger("dp.change"); $("#data_rifiuto").trigger("dp.change"); + + $("#id_articolo").on("change", function(e) { + if ($(this).val()) { + var data = $(this).selectData(); + + if (data.barcode) { + $("#barcode").val(data.barcode); + } else { + $("#barcode").val(""); + } + } + + e.preventDefault(); + + setTimeout(function(){ + $("#barcode").focus(); + }, 100); + }); + + $("#barcode").focus(); + + caricaRighe(null); }); $("#idanagrafica_c").change(function() { @@ -461,6 +505,45 @@ $("#codice_cig, #codice_cup").bind("keyup change", function(e) { $("#id_documento_fe").prop("required", true); } }); + + +function salvaArticolo() { + $("#link_form").ajaxSubmit({ + url: globals.rootdir + "/actions.php", + data: { + id_module: globals.id_module, + id_record: globals.id_record, + ajax: true, + }, + type: "post", + beforeSubmit: function(arr, $form, options) { + return $form.parsley().validate(); + }, + success: function(response){ + renderMessages(); + if(response.length > 0){ + response = JSON.parse(response); + swal({ + type: "error", + title: "'.tr('Errore').'", + text: response.error, + }); + } + + $("#barcode").val(""); + $("#id_articolo").selectReset(); + caricaRighe(null); + } + }); +} + +$("form").bind("keypress", function(e) { + if (e.keyCode == 13) { + e.preventDefault(); + salvaArticolo(); + return false; + } +}); '; // Collegamenti diretti diff --git a/modules/ddt/edit.php b/modules/ddt/edit.php index 43d63709e..c091ab716 100755 --- a/modules/ddt/edit.php +++ b/modules/ddt/edit.php @@ -361,7 +361,6 @@ if ($dir == 'entrata') {
-
0)'; $ddt = $dbo->fetchArray($ddt_query)[0]['tot']; - echo ' - - '.tr('Ddt').' - '; + // Form di inserimento riga documento echo ' - - '.tr('Ordine').' - '; - - // Lettura articoli - $art_query = 'SELECT id FROM mg_articoli WHERE attivo = 1 AND deleted_at IS NULL'; - if ($dir == 'entrata' && !setting('Permetti selezione articoli con quantità minore o uguale a zero in Documenti di Vendita')) { - $art_query .= ' AND (qta > 0 OR servizio = 1)'; - } else { - //Gli articoli possono essere creati al volo direttamente dal modale di aggiunta articolo - $art_query .= ' OR 1=1'; - } + '; } echo ' -

@@ -454,8 +467,7 @@ async function gestioneRiga(button, options) { await salvaForm("#edit-form", {}, button); // Lettura titolo e chiusura tooltip - let title = $(button).tooltipster("content"); - $(button).tooltipster("close") + let title = $(button).attr("data-title"); // Apertura modal options = options ? options : "is_riga"; @@ -465,17 +477,22 @@ async function gestioneRiga(button, options) { /** * Funzione dedicata al caricamento dinamico via AJAX delle righe del documento. */ -function caricaRighe() { +function caricaRighe(id_riga) { let container = $("#righe"); localLoading(container, true); return $.get("'.$structure->fileurl('row-list.php').'?id_module='.$id_module.'&id_record='.$id_record.'", function(data) { container.html(data); localLoading(container, false); + if (id_riga != null) { + $("tr[data-id="+ id_riga +"]").effect("highlight",1000); + } }); } $(document).ready(function() { + caricaRighe(null); + if(!$("#peso_manuale").is(":checked")){ input("peso").set($("#peso_calcolato").val()); } @@ -496,7 +513,25 @@ $(document).ready(function() { } }); - caricaRighe(); + $("#id_articolo").on("change", function(e) { + if ($(this).val()) { + var data = $(this).selectData(); + + if (data.barcode) { + $("#barcode").val(data.barcode); + } else { + $("#barcode").val(""); + } + } + + e.preventDefault(); + + setTimeout(function(){ + $("#barcode").focus(); + }, 100); + }); + + $("#barcode").focus(); }); $("#idanagrafica").change(function() { @@ -515,6 +550,44 @@ $("#idanagrafica").change(function() { } } }); + +function salvaArticolo() { + $("#link_form").ajaxSubmit({ + url: globals.rootdir + "/actions.php", + data: { + id_module: globals.id_module, + id_record: globals.id_record, + ajax: true, + }, + type: "post", + beforeSubmit: function(arr, $form, options) { + return $form.parsley().validate(); + }, + success: function(response){ + renderMessages(); + if(response.length > 0){ + response = JSON.parse(response); + swal({ + type: "error", + title: "'.tr('Errore').'", + text: response.error, + }); + } + + $("#barcode").val(""); + $("#id_articolo").selectReset(); + caricaRighe(null); + } + }); +} + +$("form").bind("keypress", function(e) { + if (e.keyCode == 13) { + e.preventDefault(); + salvaArticolo(); + return false; + } +}); '; // Collegamenti diretti diff --git a/modules/fatture/edit.php b/modules/fatture/edit.php index 1457997a7..521490df0 100755 --- a/modules/fatture/edit.php +++ b/modules/fatture/edit.php @@ -757,8 +757,7 @@ echo '
-
-
'; +
'; if (!$block_edit) { if (empty($record['ref_documento'])) { @@ -780,32 +779,13 @@ if (!$block_edit) { $interventi = $dbo->fetchArray($int_query)[0]['tot']; } - echo ' - '; - // Lettura preventivi accettati, in attesa di conferma o in lavorazione $prev_query = 'SELECT COUNT(*) AS tot FROM co_preventivi WHERE idanagrafica='.prepare($record['idanagrafica']).' AND idstato IN(SELECT id FROM co_statipreventivi WHERE is_fatturabile = 1) AND default_revision=1 AND co_preventivi.id IN (SELECT idpreventivo FROM co_righe_preventivi WHERE co_righe_preventivi.idpreventivo = co_preventivi.id AND (qta - qta_evasa) > 0)'; $preventivi = $dbo->fetchArray($prev_query)[0]['tot']; - echo ' - '; // Lettura contratti accettati, in attesa di conferma o in lavorazione $contr_query = 'SELECT COUNT(*) AS tot FROM co_contratti WHERE idanagrafica='.prepare($record['idanagrafica']).' AND idstato IN( SELECT id FROM co_staticontratti WHERE is_fatturabile = 1) AND co_contratti.id IN (SELECT idcontratto FROM co_righe_contratti WHERE co_righe_contratti.idcontratto = co_contratti.id AND (qta - qta_evasa) > 0)'; $contratti = $dbo->fetchArray($contr_query)[0]['tot']; - echo ' - '; } // Lettura ddt (entrata o uscita) @@ -819,75 +799,95 @@ if (!$block_edit) { AND `dt_causalet`.`is_importabile` = 1 AND dt_ddt.id IN (SELECT idddt FROM dt_righe_ddt WHERE dt_righe_ddt.idddt = dt_ddt.id AND (qta - qta_evasa) > 0)'; $ddt = $dbo->fetchArray($ddt_query)[0]['tot']; - echo ' - '; // Lettura ordini (cliente o fornitore) $ordini_query = 'SELECT COUNT(*) AS tot FROM or_ordini WHERE idanagrafica='.prepare($record['idanagrafica']).' AND idstatoordine IN (SELECT id FROM or_statiordine WHERE descrizione IN(\'Accettato\', \'Evaso\', \'Parzialmente evaso\', \'Parzialmente fatturato\')) AND idtipoordine=(SELECT id FROM or_tipiordine WHERE dir='.prepare($dir).') AND or_ordini.id IN (SELECT idordine FROM or_righe_ordini WHERE or_righe_ordini.idordine = or_ordini.id AND (qta - qta_evasa) > 0)'; $ordini = $dbo->fetchArray($ordini_query)[0]['tot']; - echo ' -
- - '.tr('Ordine').' + } + + // Form di inserimento riga documento + echo ' +
+ '; } ?> -
- -
- - 0) { - //echo '{( "name": "button", "type": "print", "id_module": "'.$id_module.'", "id_record": "'.$id_record.'", "class": "btn-info disabled" )}'; - } else { - //echo '{( "name": "button", "type": "print", "id_module": "'.$id_module.'", "id_record": "'.$id_record.'" )}'; - } -} -?> -
@@ -1035,8 +1035,7 @@ async function gestioneRiga(button, options) { await salvaForm("#edit-form", {}, button); // Lettura titolo e chiusura tooltip - let title = $(button).tooltipster("content"); - $(button).tooltipster("close") + let title = $(button).attr("data-title"); // Apertura modal options = options ? options : "is_riga"; @@ -1046,7 +1045,7 @@ async function gestioneRiga(button, options) { /** * Funzione dedicata al caricamento dinamico via AJAX delle righe del documento. */ -function caricaRighe() { +function caricaRighe(id_riga) { let container = $("#righe"); localLoading(container, true); @@ -1057,7 +1056,7 @@ function caricaRighe() { } $(document).ready(function () { - caricaRighe(); + caricaRighe(null); $("#data_registrazione").on("dp.change", function (e) { let data_competenza = $("#data_competenza"); @@ -1080,6 +1079,26 @@ $(document).ready(function () { updateSelectOption("idsede_destinazione", $(this).val()); $("#idreferente").selectReset(); }); + + $("#id_articolo").on("change", function(e) { + if ($(this).val()) { + var data = $(this).selectData(); + + if (data.barcode) { + $("#barcode").val(data.barcode); + } else { + $("#barcode").val(""); + } + } + + e.preventDefault(); + + setTimeout(function(){ + $("#barcode").focus(); + }, 100); + }); + + $("#barcode").focus(); }); function cambiaStato() { @@ -1137,5 +1156,43 @@ if ($dir == 'entrata') { bolloAutomatico(); });'; } + echo ' +function salvaArticolo() { + $("#link_form").ajaxSubmit({ + url: globals.rootdir + "/actions.php", + data: { + id_module: globals.id_module, + id_record: globals.id_record, + ajax: true, + }, + type: "post", + beforeSubmit: function(arr, $form, options) { + return $form.parsley().validate(); + }, + success: function(response){ + renderMessages(); + if(response.length > 0){ + response = JSON.parse(response); + swal({ + type: "error", + title: "'.tr('Errore').'", + text: response.error, + }); + } + + $("#barcode").val(""); + $("#id_articolo").selectReset(); + caricaRighe(null); + } + }); +} + +$("form").bind("keypress", function(e) { + if (e.keyCode == 13) { + e.preventDefault(); + salvaArticolo(); + return false; + } +}); '; diff --git a/modules/interventi/edit.php b/modules/interventi/edit.php index 6f48c8490..1a799da61 100755 --- a/modules/interventi/edit.php +++ b/modules/interventi/edit.php @@ -336,7 +336,13 @@ echo ' {[ "type": "textarea", "label": "'.tr('Note interne').'", "name": "informazioniaggiuntive", "class": "autosize", "value": "$informazioniaggiuntive$", "extra": "rows=\'5\'" ]}
'; } + + // Conteggio numero articoli intervento per eventuale blocco della sede di partenza + $articoli = $intervento->articoli; ?> +
+ {[ "type": "select", "label": "", "name": "idsede_partenza", "ajax-source": "sedi_azienda", "value": "$idsede_partenza$", "readonly": "isEmpty()) ? 1 : 0; ?>" ]} +
@@ -386,42 +392,42 @@ echo ' + + +
+
+

+
- -
-
-

-
- -
- - - -
-
-
"; - } - ?> - -
-
-
-
-
- - -
-
-

+
+ + +
+
+
"; + } + ?> -
-
-
+
+
+
+
+
+ + +
+
+

+
+ +
+
+
0)'; $preventivi = $dbo->fetchArray($prev_query)[0]['tot']; - echo ' - '; // Lettura contratti accettati, in attesa di conferma o in lavorazione $contr_query = 'SELECT COUNT(*) AS tot FROM co_contratti WHERE idanagrafica='.prepare($record['idanagrafica']).' AND idstato IN( SELECT id FROM co_staticontratti WHERE is_fatturabile = 1) AND co_contratti.id IN (SELECT idcontratto FROM co_righe_contratti WHERE co_righe_contratti.idcontratto = co_contratti.id AND (qta - qta_evasa) > 0)'; $contratti = $dbo->fetchArray($contr_query)[0]['tot']; - echo ' - '; // Lettura ddt (entrata o uscita) $ddt_query = 'SELECT COUNT(*) AS tot FROM dt_ddt @@ -457,77 +451,95 @@ if (!$block_edit) { AND `dt_causalet`.`is_importabile` = 1 AND dt_ddt.id IN (SELECT idddt FROM dt_righe_ddt WHERE dt_righe_ddt.idddt = dt_ddt.id AND (qta - qta_evasa) > 0)'; $ddt = $dbo->fetchArray($ddt_query)[0]['tot']; - echo ' -
- -
'; - // Lettura articoli - $art_query = 'SELECT id FROM mg_articoli WHERE attivo = 1 AND deleted_at IS NULL'; - if (!setting('Permetti selezione articoli con quantità minore o uguale a zero in Documenti di Vendita')) { - $art_query .= ' AND (qta > 0 OR servizio = 1)'; - } + // Form di inserimento riga documento + echo ' + '; } -// Conteggio numero articoli intervento per eventuale blocco della sede di partenza -$articoli = $intervento->articoli; - ?> -
- -
- {[ "type": "select", "label": "", "name": "idsede_partenza", "ajax-source": "sedi_azienda", "value": "$idsede_partenza$", "readonly": "isEmpty()) ? 1 : 0; ?>" ]} -
-
- -
-
+ +
+
+
+
+
+ + +
+
+

- -
-
-

-
- -
-
-
-
-
-
- +
+
+
+
+
+
{( "name": "filelist_and_upload", "id_module": "$id_module$", "id_record": "$id_record$", )} @@ -576,8 +588,7 @@ async function gestioneRiga(button, options) { await salvaForm("#edit-form", {}, button); // Lettura titolo e chiusura tooltip - let title = $(button).tooltipster("content"); - $(button).tooltipster("close"); + let title = $(button).attr("data-title"); // Apertura modal options = options ? options : "is_riga"; @@ -587,13 +598,16 @@ async function gestioneRiga(button, options) { /** * Funzione dedicata al caricamento dinamico via AJAX delle righe del documento. */ -function caricaRighe() { +function caricaRighe(id_riga) { let container = $("#righe"); localLoading(container, true); return $.get("'.$structure->fileurl('row-list.php').'?id_module='.$id_module.'&id_record='.$id_record.'", function(data) { container.html(data); localLoading(container, false); + if (id_riga != null) { + $("tr[data-id="+ id_riga +"]").effect("highlight",1000); + } }); } @@ -605,7 +619,7 @@ function caricaTecnici() { localLoading(container, true); return $.get("'.$structure->fileurl('ajax_tecnici.php').'?id_module='.$id_module.'&id_record='.$id_record.'", function(data) { - caricaRighe(); + caricaRighe(null); container.html(data); localLoading(container, false); }); @@ -625,9 +639,29 @@ function caricaCosti() { } $(document).ready(function() { - caricaRighe(); + caricaRighe(null); caricaTecnici(); caricaCosti(); + + $("#id_articolo").on("change", function(e) { + if ($(this).val()) { + var data = $(this).selectData(); + + if (data.barcode) { + $("#barcode").val(data.barcode); + } else { + $("#barcode").val(""); + } + } + + e.preventDefault(); + + setTimeout(function(){ + $("#barcode").focus(); + }, 100); + }); + + $("#barcode").focus(); }); var anagrafica = input("idanagrafica"); @@ -748,6 +782,44 @@ $(document).ready(function() { $("#id_documento_fe").prop("required", true); } }); + + function salvaArticolo() { + $("#link_form").ajaxSubmit({ + url: globals.rootdir + "/actions.php", + data: { + id_module: globals.id_module, + id_record: globals.id_record, + ajax: true, + }, + type: "post", + beforeSubmit: function(arr, $form, options) { + return $form.parsley().validate(); + }, + success: function(response){ + renderMessages(); + if(response.length > 0){ + response = JSON.parse(response); + swal({ + type: "error", + title: "'.tr('Errore').'", + text: response.error, + }); + } + + $("#barcode").val(""); + $("#id_articolo").selectReset(); + caricaRighe(null); + } + }); + } + + $("form").bind("keypress", function(e) { + if (e.keyCode == 13) { + e.preventDefault(); + salvaArticolo(); + return false; + } + }); '; // Collegamenti diretti diff --git a/modules/ordini/edit.php b/modules/ordini/edit.php index 7fa5f9bb5..b1742ff96 100755 --- a/modules/ordini/edit.php +++ b/modules/ordini/edit.php @@ -220,59 +220,75 @@ echo '
'; if (!$block_edit) { - echo ' -
'; - - $prev_query = 'SELECT COUNT(*) AS tot FROM co_preventivi WHERE idanagrafica='.prepare($record['idanagrafica']).' AND idstato IN(SELECT id FROM co_statipreventivi WHERE is_fatturabile = 1) AND default_revision=1 AND co_preventivi.id IN (SELECT idpreventivo FROM co_righe_preventivi WHERE co_righe_preventivi.idpreventivo = co_preventivi.id AND (qta - qta_evasa) > 0)'; - $preventivi = $dbo->fetchArray($prev_query)[0]['tot']; - if ($dir == 'entrata') { + $prev_query = 'SELECT COUNT(*) AS tot FROM co_preventivi WHERE idanagrafica='.prepare($record['idanagrafica']).' AND idstato IN(SELECT id FROM co_statipreventivi WHERE is_fatturabile = 1) AND default_revision=1 AND co_preventivi.id IN (SELECT idpreventivo FROM co_righe_preventivi WHERE co_righe_preventivi.idpreventivo = co_preventivi.id AND (qta - qta_evasa) > 0)'; + $preventivi = $dbo->fetchArray($prev_query)[0]['tot']; echo ' - '; - } - echo ' - '; +
'; - echo ' - '; - - echo ' - '; - - echo ' - '; - - echo ' - '; - - echo ' -
'; - - if ($dir == 'entrata') { + // Form di inserimento riga documento echo ' - '; - } + '; } echo ' @@ -308,8 +324,7 @@ async function gestioneRiga(button, options) { await salvaForm("#edit-form", {}, button); // Lettura titolo e chiusura tooltip - let title = $(button).tooltipster("content"); - $(button).tooltipster("close") + let title = $(button).attr("data-title"); // Apertura modal options = options ? options : "is_riga"; @@ -319,20 +334,19 @@ async function gestioneRiga(button, options) { /** * Funzione dedicata al caricamento dinamico via AJAX delle righe del documento. */ -function caricaRighe() { +function caricaRighe(id_riga) { let container = $("#righe"); localLoading(container, true); return $.get("'.$structure->fileurl('row-list.php').'?id_module='.$id_module.'&id_record='.$id_record.'", function(data) { container.html(data); localLoading(container, false); + if (id_riga != null) { + $("tr[data-id="+ id_riga +"]").effect("highlight",1000); + } }); } -$(document).ready(function() { - caricaRighe(); -}); - $("#idsede").change(function(){ updateSelectOption("idsede_destinazione", $(this).val()); $("#idreferente").selectReset(); @@ -356,6 +370,8 @@ $("#idanagrafica").change(function() { }); $(document).ready(function() { + caricaRighe(null); + $("#codice_cig, #codice_cup").bind("keyup change", function(e) { if ($("#codice_cig").val() == "" && $("#codice_cup").val() == "" ){ $("#numero_cliente").prop("required", false); @@ -363,6 +379,64 @@ $(document).ready(function() { $("#numero_cliente").prop("required", true); } }); + + $("#id_articolo").on("change", function(e) { + if ($(this).val()) { + var data = $(this).selectData(); + + if (data.barcode) { + $("#barcode").val(data.barcode); + } else { + $("#barcode").val(""); + } + } + + e.preventDefault(); + + setTimeout(function(){ + $("#barcode").focus(); + }, 100); + }); + + $("#barcode").focus(); +}); + +function salvaArticolo() { + $("#link_form").ajaxSubmit({ + url: globals.rootdir + "/actions.php", + data: { + id_module: globals.id_module, + id_record: globals.id_record, + ajax: true, + }, + type: "post", + beforeSubmit: function(arr, $form, options) { + return $form.parsley().validate(); + }, + success: function(response){ + renderMessages(); + if(response.length > 0){ + response = JSON.parse(response); + swal({ + type: "error", + title: "'.tr('Errore').'", + text: response.error, + }); + } + + $("#barcode").val(""); + $("#id_articolo").selectReset(); + caricaRighe(null); + } + }); +} + +$("form").bind("keypress", function(e) { + if (e.keyCode == 13) { + e.preventDefault(); + salvaArticolo(); + return false; + } }); '; diff --git a/modules/preventivi/edit.php b/modules/preventivi/edit.php index be16220ff..83e526615 100755 --- a/modules/preventivi/edit.php +++ b/modules/preventivi/edit.php @@ -245,30 +245,52 @@ echo '
'; if (!$block_edit) { + // Form di inserimento riga documento echo ' - '; + '; } echo ' @@ -308,8 +330,7 @@ async function gestioneRiga(button, options) { await salvaForm("#edit-form", {}, button); // Lettura titolo e chiusura tooltip - let title = $(button).tooltipster("content"); - $(button).tooltipster("close") + let title = $(button).attr("data-title"); // Apertura modal options = options ? options : "is_riga"; @@ -319,21 +340,22 @@ async function gestioneRiga(button, options) { /** * Funzione dedicata al caricamento dinamico via AJAX delle righe del documento. */ -function caricaRighe() { +function caricaRighe(id_riga) { let container = $("#righe"); localLoading(container, true); return $.get("'.$structure->fileurl('row-list.php').'?id_module='.$id_module.'&id_record='.$id_record.'", function(data) { container.html(data); localLoading(container, false); + if (id_riga != null) { + $("tr[data-id="+ id_riga +"]").effect("highlight",1000); + } }); } $(document).ready(function() { - caricaRighe(); -}); - -$(document).ready(function() { + caricaRighe(null); + $("#idanagrafica").change(function() { updateSelectOption("idanagrafica", $(this).val()); session_set("superselect,idanagrafica", $(this).val(), 0); @@ -380,6 +402,63 @@ $(document).ready(function() { }); + $("#id_articolo").on("change", function(e) { + if ($(this).val()) { + var data = $(this).selectData(); + + if (data.barcode) { + $("#barcode").val(data.barcode); + } else { + $("#barcode").val(""); + } + } + + e.preventDefault(); + + setTimeout(function(){ + $("#barcode").focus(); + }, 100); + }); + + $("#barcode").focus(); +}); + +function salvaArticolo() { + $("#link_form").ajaxSubmit({ + url: globals.rootdir + "/actions.php", + data: { + id_module: globals.id_module, + id_record: globals.id_record, + ajax: true, + }, + type: "post", + beforeSubmit: function(arr, $form, options) { + return $form.parsley().validate(); + }, + success: function(response){ + renderMessages(); + if(response.length > 0){ + response = JSON.parse(response); + swal({ + type: "error", + title: "'.tr('Errore').'", + text: response.error, + }); + } + + $("#barcode").val(""); + $("#id_articolo").selectReset(); + caricaRighe(null); + } + }); +} + +$("form").bind("keypress", function(e) { + if (e.keyCode == 13) { + e.preventDefault(); + salvaArticolo(); + return false; + } }); ';