1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-22 05:23:41 +01:00

Aggiunta libreria NumeralJS

This commit is contained in:
Thomas Zilio 2017-09-19 16:50:01 +02:00
parent 667425df8b
commit 704c25ce45
6 changed files with 35 additions and 37 deletions

View File

@ -36,6 +36,25 @@ $(document).ready(function () {
moment.locale(globals.locale);
globals.timestampFormat = moment.localeData().longDateFormat('L') + ' ' + moment.localeData().longDateFormat('LT');
// Imposta lo standard per la conversione dei numeri
numeral.register('locale', 'it', {
delimiters: {
thousands: globals.thousands,
decimal: globals.decimals,
},
abbreviations: {
thousand: 'k',
million: 'm',
billion: 'b',
trillion: 't'
},
currency: {
symbol: '€'
}
});
numeral.locale('it');
numeral.defaultFormat('0,0.' + ('0').repeat(globals.cifre_decimali));
// Orologio
clock();
@ -74,7 +93,7 @@ $(document).ready(function () {
},
function (start, end) {
// Esegue il submit del periodo selezionato e ricarica la pagina
$.get(globals.rootdir + '/core.php?period_start=' + start.format('YYYY-MM-DD') + '&period_end=' + end.format('YYYY-MM-DD'), function (data ) {
$.get(globals.rootdir + '/core.php?period_start=' + start.format('YYYY-MM-DD') + '&period_end=' + end.format('YYYY-MM-DD'), function (data) {
location.reload();
});
}
@ -1105,34 +1124,12 @@ Number.prototype.formatMoney = function (c, d, t) {
return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
}
Number.prototype.toFixedLocale = function (decimals) {
decimals = decimals || globals.cifre_decimali
return this.toFixed(decimals).toLocale();
};
String.prototype.toEnglish = function () {
var x = this.split(globals.decimals);
if (globals.thousands) {
x[0] = x[0].replace(globals.thousands, '');
}
return parseFloat(x[0] + '.' + x[1]);
return numeral(this.toString()).value();
};
String.prototype.toLocale = function () {
var x = this.split('.');
if (globals.thousands) {
x[0] = x[0].split("").reverse().join("");
x[0] = x[0].replace(/(.{3})/g, "$1" + globals.thousands);
x[0] = x[0].split("").reverse().join("");
if (x[0][0] == globals.thousands) {
x[0] = x[0].substr(1);
}
}
return x[0] + globals.decimals + x[1];
Number.prototype.toLocale = function () {
return numeral(this).format();
};
function setContrast(backgroundcolor) {

View File

@ -250,10 +250,10 @@ echo '
$("#serial_"+r).data('maximum', qta);
start_superselect();
subtotale = (subtot * qta + iva * qta).toFixedLocale(2);
subtotale = (subtot * qta + iva * qta).toLocale();
$("#subtotale_"+r).html(subtotale+" €");
$("#subtotaledettagli_"+r).html((subtot * qta).toFixedLocale(2) + " + " + (iva * qta).toFixedLocale(2));
$("#subtotaledettagli_"+r).html((subtot * qta).toLocale() + " + " + (iva * qta).toLocale());
ricalcola_totale();
}
@ -283,7 +283,7 @@ echo '
r++;
});
$('#totale').html( (totale.toFixedLocale()) + " €" );
$('#totale').html( (totale.toLocale()) + " €" );
if( totale==0 )
$('#submit_btn').hide();

View File

@ -287,8 +287,8 @@ include_once __DIR__.'/../../core.php';
totale_avere += valore;
});
$('#totale_dare').text(totale_dare.toFixedLocale());
$('#totale_avere').text(totale_avere.toFixedLocale());
$('#totale_dare').text(totale_dare.toLocale());
$('#totale_avere').text(totale_avere.toLocale());
bilancio = totale_dare - totale_avere;
@ -297,7 +297,7 @@ include_once __DIR__.'/../../core.php';
$("button[type=submit]").removeClass('hide');
}
else{
$("#testo_aggiuntivo").addClass('text-danger').html("sbilancio di " + bilancio.toFixedLocale() + " €" );
$("#testo_aggiuntivo").addClass('text-danger').html("sbilancio di " + bilancio.toLocale() + " €" );
$("button[type=submit]").addClass('hide');
}
}

View File

@ -211,8 +211,8 @@ include_once __DIR__.'/../../core.php';
totale_avere += valore;
});
$('#totale_dare').text(totale_dare.toFixedLocale());
$('#totale_avere').text(totale_avere.toFixedLocale());
$('#totale_dare').text(totale_dare.toLocale());
$('#totale_avere').text(totale_avere.toLocale());
bilancio = totale_dare-totale_avere;
@ -221,7 +221,7 @@ include_once __DIR__.'/../../core.php';
$("button[type=submit]").removeClass('hide');
}
else{
$("#testo_aggiuntivo").addClass('text-danger').html("sbilancio di " + bilancio.toFixedLocale() + " €" );
$("#testo_aggiuntivo").addClass('text-danger').html("sbilancio di " + bilancio.toLocale() + " €" );
$("button[type=submit]").addClass('hide');
}

View File

@ -175,7 +175,7 @@ echo '
$('#totale').removeClass('hide');
}
$('#diff').html(diff.toFixedLocale());
$('#totale_utente').html(totale_utente.toFixedLocale());
$('#diff').html(diff.toLocale());
$('#totale_utente').html(totale_utente.toLocale());
}
</script>

View File

@ -52,6 +52,7 @@
"jquery-form": "^4.2.1",
"jquery-ui-touch-punch": "^0.2.3",
"moment": "^2.18.1",
"numeral": "^2.0.6",
"parsleyjs": "^2.7.2",
"select2": "^4.0.3",
"select2-bootstrap-theme": "^0.1.0-beta.10",