diff --git a/assets/src/css/style.css b/assets/src/css/style.css index 58d55b08c..095e7f9e5 100755 --- a/assets/src/css/style.css +++ b/assets/src/css/style.css @@ -1041,6 +1041,10 @@ div.tip { background: #222222; } +.decimal-number { + text-align: right; +} + /* Loading specificato per un div */ .local-loader { position: relative; diff --git a/assets/src/js/functions/functions.js b/assets/src/js/functions/functions.js index b401d10c1..69178d27d 100755 --- a/assets/src/js/functions/functions.js +++ b/assets/src/js/functions/functions.js @@ -16,12 +16,21 @@ * along with this program. If not, see . */ -// Modal +/** + * Modal gestito da versioni precedenti. + * @param title + * @param href + * @param init_modal + */ function launch_modal(title, href, init_modal) { openModal(title, href); } -// Modal +/** + * Modal. + * @param title + * @param href + */ function openModal(title, href) { // Fix - Select2 does not function properly when I use it inside a Bootstrap modal. $.fn.modal.Constructor.prototype.enforceFocus = function () { @@ -73,6 +82,11 @@ function openModal(title, href) { } } +/** + * + * @param event + * @param link + */ function openLink(event, link) { if (event.ctrlKey) { window.open(link); @@ -103,7 +117,9 @@ function getUrlVars() { }); } -// Data e ora (orologio) +/** + * Data e ora (orologio) + */ function clock() { $('#datetime').html(moment().formatPHP(globals.timestamp_format)); setTimeout('clock()', 1000); @@ -143,33 +159,6 @@ function session_keep_alive() { $.get(globals.rootdir + '/core.php'); } -/** - * Funzione per gestire i contatori testuali nel formato x/total. - * Viene dato un id del campo da verificare come input, viene letto il testo nella forma [0-9]/[0-9] e viene fatto - * il replate del primo numero in base a quanti elementi sono stati trovati (valore passato per parametro) - */ -function update_counter(id, new_value) { - new_text = $('#' + id).html(); - - // Estraggo parte numerica (formato x/total) - pattern = /([^0-9]+)([0-9]+)\/([0-9]+)([^0-9]+)/; - new_text = new_text.replace(pattern, "$1" + new_value + "/$3$4"); - - // Estraggo totale (parte numerica dopo lo slash /) - matches = pattern.exec(new_text); - total = matches[3]; - - $('#' + id).html(new_text); - - if (new_value == total) { - $('#' + id).removeClass('btn-warning').removeClass('btn-danger').addClass('btn-success'); - } else if (new_value == 0) { - $('#' + id).removeClass('btn-warning').removeClass('btn-success').addClass('btn-danger'); - } else { - $('#' + id).removeClass('btn-success').removeClass('btn-danger').addClass('btn-warning'); - } -} - function setContrast(backgroundcolor) { var rgb = []; var bg = String(backgroundcolor); @@ -237,9 +226,7 @@ function message(element) { confirmButtonText: button, confirmButtonClass: btn_class, onOpen: function () { - start_superselect(); - start_inputmask(); - start_datepickers(); + restart_inputs(); }, preConfirm: function () { $form = $('#swal-form'); @@ -468,8 +455,10 @@ function prepareForm(form) { } } +/** + * Visualizzazione dei messaggi attivi tramite toastr. + */ function renderMessages() { - // Visualizzazione messaggi $.ajax({ url: globals.rootdir + '/ajax.php', type: 'get', @@ -522,14 +511,17 @@ function restart_inputs() { start_datepickers(); start_inputmask(); + initNumbers(); start_superselect(); // Autosize per le textarea autosize($('.autosize')); } +/** + * Messaggio di avviso salvataggio a comparsa sulla destra solo nella versione a desktop intero + */ function alertPush() { - // Messaggio di avviso salvataggio a comparsa sulla destra solo nella versione a desktop intero if ($(window).width() > 1023) { var i = 0; @@ -559,6 +551,13 @@ function alertPush() { }); } +/** + * + * @param button + * @param form + * @param data + * @returns {Promise} + */ function salvaForm(button, form, data = {}) { return new Promise(function (resolve, reject) { // Caricamento visibile nel pulsante diff --git a/assets/src/js/functions/numbers.js b/assets/src/js/functions/numbers.js new file mode 100644 index 000000000..e0def09c1 --- /dev/null +++ b/assets/src/js/functions/numbers.js @@ -0,0 +1,31 @@ +function initNumbers() { + $('.decimal-number').not('.bound').each(function () { + let $this = $(this); + + let min = $this.attr('min-value') && $this.attr('min-value') !== "undefined" ? $this.attr('min-value') : null; + let max = $this.attr('max-value') && $this.attr('max-value') !== "undefined" ? $this.attr('max-value') : null; + + let decimals = $this.attr('decimals') ? $this.attr('decimals') : globals.cifre_decimali; + + let autonumeric = new AutoNumeric(this, { + caretPositionOnFocus: "decimalLeft", + allowDecimalPadding: true, + currencySymbolPlacement: "s", + negativePositiveSignPlacement: "p", + decimalCharacter: globals.decimals, + decimalCharacterAlternative: ".", + digitGroupSeparator: globals.thousands, + emptyInputBehavior: min ? min : "zero", + overrideMinMaxLimits: "ignore", + modifyValueOnWheel: false, + outputFormat: "string", + unformatOnSubmit: true, + watchExternalChanges: true, + minimumValue: min ? min : "-10000000000000", + maximumValue: max ? max : "10000000000000", + decimalPlaces: decimals, + }); + + $this.data("autonumeric", autonumeric); + }).addClass('bound'); +} diff --git a/assets/src/js/functions/prototypes.js b/assets/src/js/functions/prototypes.js index 85390394f..1e91e7c97 100755 --- a/assets/src/js/functions/prototypes.js +++ b/assets/src/js/functions/prototypes.js @@ -39,6 +39,6 @@ Number.prototype.toLocale = function () { jQuery.fn.scrollTo = function (elem, speed) { $(this).animate({ scrollTop: $(this).scrollTop() - $(this).offset().top + $(elem).offset().top - }, speed == undefined ? 1000 : speed); + }, speed === undefined ? 1000 : speed); return this; }; diff --git a/files/impianti/componente.ini b/files/impianti/componente.ini old mode 100644 new mode 100755 diff --git a/gulpfile.js b/gulpfile.js index 74d6309a8..44079ad01 100755 --- a/gulpfile.js +++ b/gulpfile.js @@ -94,6 +94,7 @@ const JS = gulp.parallel(() => { 'datatables.net-scroller/js/dataTables.scroller.js', 'datatables.net-select/js/dataTables.select.js', 'dropzone/dist/dropzone.js', + 'autonumeric/dist/autoNumeric.min.js', 'eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js', 'fullcalendar/dist/fullcalendar.js', 'geocomplete/jquery.geocomplete.js', diff --git a/include/common/riga.php b/include/common/riga.php index 607b0cef4..786019cb3 100755 --- a/include/common/riga.php +++ b/include/common/riga.php @@ -33,7 +33,7 @@ echo ' // Quantità echo '
- {[ "type": "number", "label": "'.tr('Q.tà').'", "name": "qta", "required": 1, "value": "'.$result['qta'].'", "decimals": "qta"'.(isset($result['max_qta']) ? ', "icon-after": "/ '.numberFormat($result['max_qta'], 'qta').' "' : '').', "min-value": "'.Translator::numberToLocale($result['qta_evasa']).'" ]} + {[ "type": "number", "label": "'.tr('Q.tà').'", "name": "qta", "required": 1, "value": "'.$result['qta'].'", "decimals": "qta"'.(isset($result['max_qta']) ? ', "icon-after": "/ '.numberFormat($result['max_qta'], 'qta').' "' : '').', "min-value": "'.$result['qta_evasa'].'" ]}
'; // Unità di misura diff --git a/modules/fatture/edit.php b/modules/fatture/edit.php index 44be79b29..1160641c4 100755 --- a/modules/fatture/edit.php +++ b/modules/fatture/edit.php @@ -183,8 +183,6 @@ elseif ($record['stato'] == 'Bozza') { {[ "type": "date", "class":"data_competenza) < dateFormat($fattura->data)) ? 'unblockable' : ''; ?>", "label": "", "name": "data_competenza", "required": 1, "value": "$data_competenza$", "min-date": "$data_registrazione$", "help": "" ]} - - diff --git a/modules/impianti/modutil.php b/modules/impianti/modutil.php index 5fc48ec37..508fead68 100755 --- a/modules/impianti/modutil.php +++ b/modules/impianti/modutil.php @@ -30,8 +30,9 @@ function crea_form_componente($contenuto) $fields[$key] = '
'.$value.'
'; } - echo $title; - echo '
'; - echo PHP_EOL.implode(PHP_EOL, $fields).PHP_EOL.''; - echo '
'; + echo $title.' +
+ '.implode(PHP_EOL, $fields).' + +
'; } diff --git a/package.json b/package.json index 2df9dca89..d38707385 100755 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "main": "gulpfile.js", "dependencies": { "admin-lte": "^2.4.0", + "autonumeric": "^4.6.0", "autosize": "^3.0.21", "bootstrap": "^3.3.7", "bootstrap-colorpicker": "2.5.1", diff --git a/src/Common/Components/Article.php b/src/Common/Components/Article.php old mode 100644 new mode 100755 diff --git a/src/Common/Components/Discount.php b/src/Common/Components/Discount.php old mode 100644 new mode 100755 diff --git a/src/Common/Components/MorphTrait.php b/src/Common/Components/MorphTrait.php old mode 100644 new mode 100755 diff --git a/src/Common/Components/Row.php b/src/Common/Components/Row.php old mode 100644 new mode 100755 diff --git a/src/Common/Document.php b/src/Common/Document.php old mode 100644 new mode 100755 diff --git a/src/Common/Model.php b/src/Common/Model.php old mode 100644 new mode 100755 diff --git a/src/Common/ReferenceInterface.php b/src/Common/ReferenceInterface.php old mode 100644 new mode 100755 diff --git a/src/HTMLBuilder/Handler/DefaultHandler.php b/src/HTMLBuilder/Handler/DefaultHandler.php index 8887e47c4..7dbbad05b 100755 --- a/src/HTMLBuilder/Handler/DefaultHandler.php +++ b/src/HTMLBuilder/Handler/DefaultHandler.php @@ -235,7 +235,7 @@ class DefaultHandler implements HandlerInterface */ protected function number(&$values, &$extras) { - $values['class'][] = 'inputmask-decimal'; + $values['class'][] = 'decimal-number'; $values['value'] = !empty($values['value']) ? $values['value'] : 0; @@ -245,20 +245,17 @@ class DefaultHandler implements HandlerInterface if (is_numeric($values['decimals'])) { $decimals = $values['decimals']; } elseif (starts_with($values['decimals'], 'qta')) { - // Se non è previsto un valore minimo, lo imposta a 1 - $values['min-value'] = isset($values['min-value']) ? $values['min-value'] : 0; - $decimals = setting('Cifre decimali per quantità'); $values['decimals'] = $decimals; + + // Se non è previsto un valore minimo, lo imposta a 1 + $values['min-value'] = isset($values['min-value']) ? $values['min-value'] : '0.'.str_repeat('0', $decimals - 1).'1'; } } - // Controllo sulla correttezza sintattica del valore impostato - $values['value'] = (formatter()->isStandardNumber($values['value'])) ? \Translator::numberToLocale($values['value'], $decimals) : $values['value']; - + // Delega al metodo "text", per la generazione del codice HTML $values['type'] = 'text'; - // Delega al metodo "text", per la generazione del codice HTML return $this->text($values, $extras); }