$(document).ready(function () { $('#loader').hide(); }); 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 (reinvio == "DOMANDA") { var object = { cod_fis_impresa: valore, conferma_tab: true, tab_active: 'istaTab' } $.redirect("domanda.php", object); } else if (reinvio == "DOMANDA_ADESIONE") { var object = { cod_fis_impresa: valore, tab_active: 'istaTab' } $.redirect("presenta_domanda.php", object); } else { document.location.href = 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 }) } } 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 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 + 'dashboard.php'); } else { functionSwall('error', risp.erroreDescrizione, ""); } }); } else { $('#loader').hide(); functionSwall('error', "E' necessario 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 activaTab(tab) { // console.log(tab); $('.nav-tabs a[href="#' + tab + '"]').tab('show'); } /* * Download forzato di un file */ function downloadURL(url) { // console.log(url); // document.location.href=(url); var hiddenIFrameID = 'hiddenDownloader', iframe = document.getElementById(hiddenIFrameID); if (iframe === null) { iframe = document.createElement('iframe'); iframe.id = hiddenIFrameID; iframe.style.display = 'none'; document.body.appendChild(iframe); } iframe.src = url; }