Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 

258 righe
8.1 KiB

$(document).ready(function () {
$('#loader').hide();
});
function b64DecodeUnicode(str) {
// Going backwards: from bytestream, to percent-encoding, to original string.
return decodeURIComponent(atob(str).split('').map(function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));
}
function functionSwall(mode, testo, reinvio, valore) {
var scrivotesto = "";
var indirizzo = "";
if (testo != "") {
scrivotesto = testo;
}
if (reinvio != "") {
indirizzo = reinvio;
} else {
indirizzo = "";
}
if (mode == "success") {
Swal.fire({
type: 'success',
title: 'OK',
text: scrivotesto,
showCancelButton: false,
confirmButtonColor: '#3085d6',
confirmButtonText: 'OK',
allowOutsideClick: false
}).then((result) => {
if (result.value) {
if(indirizzo!=""){
$.redirect(indirizzo);
}
}
});
} else if (mode == "error") {
if (testo == "") {
testo = "Al momento non è possibile completare l'operazione";
}
Swal.fire({
type: 'error',
title: 'Attenzione',
html: testo,
allowOutsideClick: false
}).then((result) => {
// if (result.value) {
// if(indirizzo!="error")
// $.redirect(indirizzo);//document.location.href = indirizzo;
//
// }
});
} else {
if (testo == "") {
testo = "Al momento non è possibile completare l'operazione";
}
Swal.fire({
type: mode,
title: 'Attenzione',
html: testo,
allowOutsideClick: false
});
}
}
function postdataClassic(url, oggetto, callback) {
$.ajax({
url: url,
method: "POST",
data: oggetto,
success: callback,
error: function (reason, xhr) {
console.log("error in processing your request", reason);
}
});
}
function postdata(url, oggetto, callback) {
$.ajax({
url: url,
method: "POST",
data: oggetto,
processData: false,
contentType: false,
success: callback,
error: function (reason, xhr) {
console.log("error in processing your request", reason);
}
});
}
function getdata(url, callback) {
$.ajax({
url: url,
method: "POST",
success: callback,
error: function (reason, xhr) {
console.log("error in processing your request", reason);
}
});
}
function resettaform(idform) {
$("#" + idform)[0].reset();
console.log("fatto");
}
function checkViewConsent(url) {
if (CONSENSO == 0) {
functionSwall('error', "E' necessario registrare i propri dati e prestare il consenso al trattamento dei dati per usufruire dei servizi della piattaforma", "");
} else {
document.location.href = url;
}
}
function saveConsenso() {
$('#loader').show();
var consenso = document.getElementById('consenso_informativo').checked;
if (document.getElementById('consenso_informativo').checked) {
var object = {
consenso: consenso
};
postdataClassic(WS_CALL + "?module=account&action=saveConsenso", object, function (response) {
$('#loader').hide();
var risp = jQuery.parseJSON(response);
if (risp.esito === 1) {
functionSwall('success', 'Operazione Avvenuta con successo!!', BASE_HTTP + 'index.php');
} else {
functionSwall('error', risp.erroreDescrizione, "");
}
});
} else {
$('#loader').hide();
functionSwall('error', "E' necessario registrare i propri dati e prestare il consenso al trattamento dei dati per usufruire dei servizi della piattaforma", "");
}
}
function codiceFISCALE(codice_fiscale)
{
var cf = codice_fiscale.toUpperCase();
var cfReg = /^[A-Z]{6}\d{2}[A-Z]\d{2}[A-Z]\d{3}[A-Z]$/;
if (!cfReg.test(cf))
return false;
var set1 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var set2 = "ABCDEFGHIJABCDEFGHIJKLMNOPQRSTUVWXYZ";
var setpari = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var setdisp = "BAKPLCQDREVOSFTGUHMINJWZYX";
var s = 0;
for (i = 1; i <= 13; i += 2)
s += setpari.indexOf(set2.charAt(set1.indexOf(cf.charAt(i))));
for (i = 0; i <= 14; i += 2)
s += setdisp.indexOf(set2.charAt(set1.indexOf(cf.charAt(i))));
if (s % 26 != cf.charCodeAt(15) - 'A'.charCodeAt(0))
return false;
return true;
}
function number_format(number, decimals, decPoint, thousandsSep) { // eslint-disable-line camelcase
// example 1: number_format(1234.56)
// returns 1: '1,235'
// example 2: number_format(1234.56, 2, ',', ' ')
// returns 2: '1 234,56'
// example 3: number_format(1234.5678, 2, '.', '')
// returns 3: '1234.57'
// example 4: number_format(67, 2, ',', '.')
// returns 4: '67,00'
// example 5: number_format(1000)
// returns 5: '1,000'
// example 6: number_format(67.311, 2)
// returns 6: '67.31'
// example 7: number_format(1000.55, 1)
// returns 7: '1,000.6'
// example 8: number_format(67000, 5, ',', '.')
// returns 8: '67.000,00000'
// example 9: number_format(0.9, 0)
// returns 9: '1'
// example 10: number_format('1.20', 2)
// returns 10: '1.20'
// example 11: number_format('1.20', 4)
// returns 11: '1.2000'
// example 12: number_format('1.2000', 3)
// returns 12: '1.200'
// example 13: number_format('1 000,50', 2, '.', ' ')
// returns 13: '100 050.00'
// example 14: number_format(1e-8, 8, '.', '')
// returns 14: '0.00000001'
number = (number + '').replace(/[^0-9+\-Ee.]/g, '');
var n = !isFinite(+number) ? 0 : +number;
var prec = !isFinite(+decimals) ? 0 : Math.abs(decimals);
var sep = (typeof thousandsSep === 'undefined') ? ',' : thousandsSep;
var dec = (typeof decPoint === 'undefined') ? '.' : decPoint;
var s = '';
var toFixedFix = function (n, prec) {
if (('' + n).indexOf('e') === -1) {
return +(Math.round(n + 'e+' + prec) + 'e-' + prec);
} else {
var arr = ('' + n).split('e');
var sig = '';
if (+arr[1] + prec > 0) {
sig = '+';
}
return (+(Math.round(+arr[0] + 'e' + sig + (+arr[1] + prec)) + 'e-' + prec)).toFixed(prec);
}
};
// @todo: for IE parseFloat(0.55).toFixed(0) = 0;
s = (prec ? toFixedFix(n, prec).toString() : '' + Math.round(n)).split('.');
if (s[0].length > 3) {
s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);
}
if ((s[1] || '').length < prec) {
s[1] = s[1] || '';
s[1] += new Array(prec - s[1].length + 1).join('0');
}
return s.join(dec);
}
function dataTableEventXhr() {
$('#' + $('.dataTable').attr('id')).on('xhr.dt', function (e, settings, json, xhr) {
if (json.esito <= 0) {
Swal.fire({
title: "Attenzione",
text: json.erroreDescrizione,
icon: "warning",
closeModal: false,
showCancelButton: false,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'OK'
}).then((result) => {
// if (result.value) {
$.redirect(BASE_HTTP + "login.php");
// }
});
}
});
}
function goToPage(page = null, private_section = true ){
if(page !== null){
if(private_section){
$.redirect(HTTP_PRIVATE_SECTION +page+".php");
}else{
$.redirect(page+".php");
}
}
}
/*Aggiunge gli zeri decimali in caso di nessun decimale inserito*/
function addTrailingZeros(num) {
const n = num.split(',');
var int = n[0];
var dec = (n[1] ? n[1] : '00');
return int+','+dec;
}