Merge branch 'autonumeric'
This commit is contained in:
commit
099cda6fcb
|
@ -1041,6 +1041,10 @@ div.tip {
|
||||||
background: #222222;
|
background: #222222;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.decimal-number {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
/* Loading specificato per un div */
|
/* Loading specificato per un div */
|
||||||
.local-loader {
|
.local-loader {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
|
@ -16,12 +16,21 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Modal
|
/**
|
||||||
|
* Modal gestito da versioni precedenti.
|
||||||
|
* @param title
|
||||||
|
* @param href
|
||||||
|
* @param init_modal
|
||||||
|
*/
|
||||||
function launch_modal(title, href, init_modal) {
|
function launch_modal(title, href, init_modal) {
|
||||||
openModal(title, href);
|
openModal(title, href);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Modal
|
/**
|
||||||
|
* Modal.
|
||||||
|
* @param title
|
||||||
|
* @param href
|
||||||
|
*/
|
||||||
function openModal(title, href) {
|
function openModal(title, href) {
|
||||||
// Fix - Select2 does not function properly when I use it inside a Bootstrap modal.
|
// Fix - Select2 does not function properly when I use it inside a Bootstrap modal.
|
||||||
$.fn.modal.Constructor.prototype.enforceFocus = function () {
|
$.fn.modal.Constructor.prototype.enforceFocus = function () {
|
||||||
|
@ -73,6 +82,11 @@ function openModal(title, href) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param event
|
||||||
|
* @param link
|
||||||
|
*/
|
||||||
function openLink(event, link) {
|
function openLink(event, link) {
|
||||||
if (event.ctrlKey) {
|
if (event.ctrlKey) {
|
||||||
window.open(link);
|
window.open(link);
|
||||||
|
@ -103,7 +117,9 @@ function getUrlVars() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Data e ora (orologio)
|
/**
|
||||||
|
* Data e ora (orologio)
|
||||||
|
*/
|
||||||
function clock() {
|
function clock() {
|
||||||
$('#datetime').html(moment().formatPHP(globals.timestamp_format));
|
$('#datetime').html(moment().formatPHP(globals.timestamp_format));
|
||||||
setTimeout('clock()', 1000);
|
setTimeout('clock()', 1000);
|
||||||
|
@ -143,33 +159,6 @@ function session_keep_alive() {
|
||||||
$.get(globals.rootdir + '/core.php');
|
$.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) {
|
function setContrast(backgroundcolor) {
|
||||||
var rgb = [];
|
var rgb = [];
|
||||||
var bg = String(backgroundcolor);
|
var bg = String(backgroundcolor);
|
||||||
|
@ -237,9 +226,7 @@ function message(element) {
|
||||||
confirmButtonText: button,
|
confirmButtonText: button,
|
||||||
confirmButtonClass: btn_class,
|
confirmButtonClass: btn_class,
|
||||||
onOpen: function () {
|
onOpen: function () {
|
||||||
start_superselect();
|
restart_inputs();
|
||||||
start_inputmask();
|
|
||||||
start_datepickers();
|
|
||||||
},
|
},
|
||||||
preConfirm: function () {
|
preConfirm: function () {
|
||||||
$form = $('#swal-form');
|
$form = $('#swal-form');
|
||||||
|
@ -468,8 +455,10 @@ function prepareForm(form) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Visualizzazione dei messaggi attivi tramite toastr.
|
||||||
|
*/
|
||||||
function renderMessages() {
|
function renderMessages() {
|
||||||
// Visualizzazione messaggi
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: globals.rootdir + '/ajax.php',
|
url: globals.rootdir + '/ajax.php',
|
||||||
type: 'get',
|
type: 'get',
|
||||||
|
@ -522,14 +511,17 @@ function restart_inputs() {
|
||||||
start_datepickers();
|
start_datepickers();
|
||||||
start_inputmask();
|
start_inputmask();
|
||||||
|
|
||||||
|
initNumbers();
|
||||||
start_superselect();
|
start_superselect();
|
||||||
|
|
||||||
// Autosize per le textarea
|
// Autosize per le textarea
|
||||||
autosize($('.autosize'));
|
autosize($('.autosize'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Messaggio di avviso salvataggio a comparsa sulla destra solo nella versione a desktop intero
|
||||||
|
*/
|
||||||
function alertPush() {
|
function alertPush() {
|
||||||
// Messaggio di avviso salvataggio a comparsa sulla destra solo nella versione a desktop intero
|
|
||||||
if ($(window).width() > 1023) {
|
if ($(window).width() > 1023) {
|
||||||
var i = 0;
|
var i = 0;
|
||||||
|
|
||||||
|
@ -559,6 +551,13 @@ function alertPush() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param button
|
||||||
|
* @param form
|
||||||
|
* @param data
|
||||||
|
* @returns {Promise<unknown>}
|
||||||
|
*/
|
||||||
function salvaForm(button, form, data = {}) {
|
function salvaForm(button, form, data = {}) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
// Caricamento visibile nel pulsante
|
// Caricamento visibile nel pulsante
|
||||||
|
|
|
@ -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');
|
||||||
|
}
|
|
@ -39,6 +39,6 @@ Number.prototype.toLocale = function () {
|
||||||
jQuery.fn.scrollTo = function (elem, speed) {
|
jQuery.fn.scrollTo = function (elem, speed) {
|
||||||
$(this).animate({
|
$(this).animate({
|
||||||
scrollTop: $(this).scrollTop() - $(this).offset().top + $(elem).offset().top
|
scrollTop: $(this).scrollTop() - $(this).offset().top + $(elem).offset().top
|
||||||
}, speed == undefined ? 1000 : speed);
|
}, speed === undefined ? 1000 : speed);
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
|
@ -94,6 +94,7 @@ const JS = gulp.parallel(() => {
|
||||||
'datatables.net-scroller/js/dataTables.scroller.js',
|
'datatables.net-scroller/js/dataTables.scroller.js',
|
||||||
'datatables.net-select/js/dataTables.select.js',
|
'datatables.net-select/js/dataTables.select.js',
|
||||||
'dropzone/dist/dropzone.js',
|
'dropzone/dist/dropzone.js',
|
||||||
|
'autonumeric/dist/autoNumeric.min.js',
|
||||||
'eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js',
|
'eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js',
|
||||||
'fullcalendar/dist/fullcalendar.js',
|
'fullcalendar/dist/fullcalendar.js',
|
||||||
'geocomplete/jquery.geocomplete.js',
|
'geocomplete/jquery.geocomplete.js',
|
||||||
|
|
|
@ -33,7 +33,7 @@ echo '
|
||||||
// Quantità
|
// Quantità
|
||||||
echo '
|
echo '
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
{[ "type": "number", "label": "'.tr('Q.tà').'", "name": "qta", "required": 1, "value": "'.$result['qta'].'", "decimals": "qta"'.(isset($result['max_qta']) ? ', "icon-after": "<span class=\"tip\" title=\"'.tr("L'elemento è collegato a un documento: la quantità massima ammessa è relativa allo stato di evasione dell'elemento nel documento di origine (quantità dell'elemento / quantità massima ammessa)").'\">/ '.numberFormat($result['max_qta'], 'qta').' <i class=\"fa fa-question-circle-o\"></i></span>"' : '').', "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": "<span class=\"tip\" title=\"'.tr("L'elemento è collegato a un documento: la quantità massima ammessa è relativa allo stato di evasione dell'elemento nel documento di origine (quantità dell'elemento / quantità massima ammessa)").'\">/ '.numberFormat($result['max_qta'], 'qta').' <i class=\"fa fa-question-circle-o\"></i></span>"' : '').', "min-value": "'.$result['qta_evasa'].'" ]}
|
||||||
</div>';
|
</div>';
|
||||||
|
|
||||||
// Unità di misura
|
// Unità di misura
|
||||||
|
|
|
@ -183,8 +183,6 @@ elseif ($record['stato'] == 'Bozza') {
|
||||||
{[ "type": "date", "class":"<?php echo (dateFormat($fattura->data_competenza) < dateFormat($fattura->data)) ? 'unblockable' : ''; ?>", "label": "<?php echo tr('Data competenza'); ?>", "name": "data_competenza", "required": 1, "value": "$data_competenza$", "min-date": "$data_registrazione$", "help": "<?php echo tr('Data nella quale considerare il movimento contabile, che può essere posticipato rispetto la data della fattura'); ?>" ]}
|
{[ "type": "date", "class":"<?php echo (dateFormat($fattura->data_competenza) < dateFormat($fattura->data)) ? 'unblockable' : ''; ?>", "label": "<?php echo tr('Data competenza'); ?>", "name": "data_competenza", "required": 1, "value": "$data_competenza$", "min-date": "$data_registrazione$", "help": "<?php echo tr('Data nella quale considerare il movimento contabile, che può essere posticipato rispetto la data della fattura'); ?>" ]}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
if ($dir == 'entrata') {
|
if ($dir == 'entrata') {
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -30,8 +30,9 @@ function crea_form_componente($contenuto)
|
||||||
$fields[$key] = '<div class="col-md-4">'.$value.'</div>';
|
$fields[$key] = '<div class="col-md-4">'.$value.'</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
echo $title;
|
echo $title.'
|
||||||
echo '<div class="row">';
|
<div class="row">
|
||||||
echo PHP_EOL.implode(PHP_EOL, $fields).PHP_EOL.'<script>start_inputmask( "#info_componente" );</script>';
|
'.implode(PHP_EOL, $fields).'
|
||||||
echo '</div>';
|
<script>restart_inputs()</script>
|
||||||
|
</div>';
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
"main": "gulpfile.js",
|
"main": "gulpfile.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"admin-lte": "^2.4.0",
|
"admin-lte": "^2.4.0",
|
||||||
|
"autonumeric": "^4.6.0",
|
||||||
"autosize": "^3.0.21",
|
"autosize": "^3.0.21",
|
||||||
"bootstrap": "^3.3.7",
|
"bootstrap": "^3.3.7",
|
||||||
"bootstrap-colorpicker": "2.5.1",
|
"bootstrap-colorpicker": "2.5.1",
|
||||||
|
|
|
@ -235,7 +235,7 @@ class DefaultHandler implements HandlerInterface
|
||||||
*/
|
*/
|
||||||
protected function number(&$values, &$extras)
|
protected function number(&$values, &$extras)
|
||||||
{
|
{
|
||||||
$values['class'][] = 'inputmask-decimal';
|
$values['class'][] = 'decimal-number';
|
||||||
|
|
||||||
$values['value'] = !empty($values['value']) ? $values['value'] : 0;
|
$values['value'] = !empty($values['value']) ? $values['value'] : 0;
|
||||||
|
|
||||||
|
@ -245,20 +245,17 @@ class DefaultHandler implements HandlerInterface
|
||||||
if (is_numeric($values['decimals'])) {
|
if (is_numeric($values['decimals'])) {
|
||||||
$decimals = $values['decimals'];
|
$decimals = $values['decimals'];
|
||||||
} elseif (starts_with($values['decimals'], 'qta')) {
|
} 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à');
|
$decimals = setting('Cifre decimali per quantità');
|
||||||
$values['decimals'] = $decimals;
|
$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
|
// Delega al metodo "text", per la generazione del codice HTML
|
||||||
$values['value'] = (formatter()->isStandardNumber($values['value'])) ? \Translator::numberToLocale($values['value'], $decimals) : $values['value'];
|
|
||||||
|
|
||||||
$values['type'] = 'text';
|
$values['type'] = 'text';
|
||||||
|
|
||||||
// Delega al metodo "text", per la generazione del codice HTML
|
|
||||||
return $this->text($values, $extras);
|
return $this->text($values, $extras);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue