diff --git a/include/common/importa.php b/include/common/importa.php index 042e02a7c..147e418fb 100644 --- a/include/common/importa.php +++ b/include/common/importa.php @@ -325,6 +325,7 @@ echo ' function ricalcola_totale() { totale = 0.00; + totale_qta = 0; $('input[id*=qta_]').each(function() { qta = $(this).val().toEnglish(); @@ -347,6 +348,8 @@ echo ' if(subtot) { totale += subtot * qta + iva * qta; } + + totale_qta += qta; }); $('#totale').html((totale.toLocale()) + " " + globals.currency); @@ -355,7 +358,7 @@ echo ' if (empty($options['allow-empty'])) { echo ' - if (tot_qta > 0) + if (totale_qta > 0) $("#submit_btn").show(); else $("#submit_btn").hide();'; diff --git a/include/src/Components/Description.php b/include/src/Components/Description.php index 911aa5694..4c59af775 100644 --- a/include/src/Components/Description.php +++ b/include/src/Components/Description.php @@ -95,10 +95,17 @@ abstract class Description extends Model throw new \InvalidArgumentException(); } + if ($this->hasOriginal()) { + $original = $this->getOriginal(); + } + $this->qta = 0; $result = parent::delete(); - $this->parent->fixStato($this); + // Fix stato automatico + if ($this->hasOriginal()) { + $original->parent->fixStato($this); + } return $result; } @@ -214,7 +221,12 @@ abstract class Description extends Model { $result = parent::save($options); - $this->parent->fixStato($this); + // Fix stato automatico + if ($this->hasOriginal()) { + $original = $this->getOriginal(); + + $original->parent->fixStato($this); + } return $result; } diff --git a/lib/functions.js b/lib/functions.js index 039026ce5..f2c2dfbf4 100644 --- a/lib/functions.js +++ b/lib/functions.js @@ -272,18 +272,15 @@ $(document).ready(function () { if (hash && hash != '#tab_0') { $('ul.nav-tabs a[href="' + hash + '"]').tab('show').trigger('shown.bs.tab'); } else { - location.hash = ''; + removeHash(); } - $(window).bind("hashchange", function(){ - var hash = location.hash; - console.log(hash); - - if (!hash || hash == '#tab_0') { - location.hash = ''; + $(window).bind('beforeunload', function(){ + if (location.hash == '#tab_0') { + removeHash(); } }); - + // Nel caso la navigazione sia da mobile, disabilito il ritorno al punto precedente if (!isMobile.any()) { // Salvo lo scroll per riportare qui l'utente al reload @@ -1784,3 +1781,7 @@ function submitAjax(form, data = {}, callback = null, errorCallback = null) { return valid; } + +function removeHash() { + history.replaceState(null, null, ' '); +} diff --git a/lib/functions.php b/lib/functions.php index a2a493c13..7b821c40f 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -283,6 +283,7 @@ function redirectOperation($id_module, $id_record) if (!empty($backto)) { $hash = filter('hash'); $hash = !starts_with($hash, '#') ? '#'.$hash : $hash; + $hash = $hash == '#tab_0' ? '' : $hash; if ($backto == 'record-edit') { redirect(ROOTDIR.'/editor.php?id_module='.$id_module.'&id_record='.$id_record.$hash); diff --git a/modules/anagrafiche/edit.php b/modules/anagrafiche/edit.php index 4934f2600..ac0087c17 100644 --- a/modules/anagrafiche/edit.php +++ b/modules/anagrafiche/edit.php @@ -26,7 +26,7 @@ if (!$is_cliente) { ?> -