// Var controllo modifiche form var sys_frm_need_confirm = false; function _sys_logout() { if (confirm('Effettuare il logout?')) { document.location = "logout.php"; } } function _sys_timestamp() { var d = new Date(); return d.getTime(); } function _sys_select_active_menu() { $('.tooltip').hide(); var sidmenu = $('#mod_id_menu').val(); $('#menu_' + sidmenu).addClass("active"); var sidmenuitem = $('#mod_id_menu_item').val(); $("li[name=menu_item]").removeClass("active"); $('#menu_item_' + sidmenuitem).addClass("active"); } function _sys_load_page(surl,sdata) { $('.tooltip').hide(); $(document).ajaxStart(function() { Pace.restart(); }); if (surl.indexOf("?") > 0 ) { surl += '&sys_timestamp=' + _sys_timestamp(); }else { surl += '?sys_timestamp=' + _sys_timestamp(); } _sys_ajax_call(surl,sdata,"main-content"); _sys_select_active_menu(); } function _sys_show_communication() { _sys_modal_show("Comunicazione di sistema","https://app.leti.eu.com/inc/ajax/sys-communication.php"); } function _sys_show_calendar() { $('.tooltip').hide(); _sys_modal_show("Calendario","https://app.leti.eu.com/inc/ajax/sys-calendar.php"); } function _sys_modal_show_err(stitle,stext,sclass,dim) { $('.tooltip').hide(); $('#sysErrModal').addClass(sclass); $('#sysErrModalTitle').html(stitle); $('#sysErrModalContent').html(stext); $('#btn-modal-close').removeClass("btn-primary"); $('#btn-modal-close').addClass("btn-outline"); _sys_set_modal_dim('sysErrModal', dim); $('#sysErrModal').modal('show'); } function _sys_modal_show_danger(stitle,stext) { $('.tooltip').hide(); _sys_modal_show_err(stitle,stext,"modal-danger") } function _sys_modal_show(stitle,surl, sdim) { $('.tooltip').hide(); _sys_modal_show_footer(stitle,surl,"", sdim); } function _sys_nonmodal_show(stitle,surl, sdim) { $('.tooltip').hide(); _sys_nonmodal_show_footer(stitle,surl,"", sdim); } function _sys_set_modal_dim(name, dim) { var element = $('#'+name+' .modal-dialog'); element.removeClass("modal-sm"); element.removeClass("modal-xl"); element.removeClass("modal-lg"); if (["sm", "md", "xl"].indexOf(dim) >= 0) { if (dim != "md") { element.addClass("modal-"+dim); } } else { element.addClass("modal-lg"); } } function _sys_modal_show_file(stitle,surl,dim) { var sfooter = ""; $('.tooltip').hide(); $('#sysModal').removeClass("modal-danger"); $('#btn-modal-close').addClass("btn-primary"); $('#btn-modal-close').removeClass("btn-outline"); _sys_set_modal_dim('sysModal', dim); $('#sysModalContentFile').load(surl, function(){ var sbtnClose = ''; $('#sysModalFooterFile').html(sfooter + sbtnClose); $('#sysModalTitleFile').html(stitle); $('#sysModalFile').modal({show:true,backdrop:'static'}); }); } function _sys_modal_show_signature(stitle,surl,dim) { var sfooter = ""; $('.tooltip').hide(); $('#sysModal').removeClass("modal-danger"); $('#btn-modal-close').addClass("btn-primary"); $('#btn-modal-close').removeClass("btn-outline"); _sys_set_modal_dim('sysModal', dim); $('#sysModalContentSignature').load(surl, function(){ var sbtnClose = ''; $('#sysModalFooterSignature').html(sfooter + sbtnClose); $('#sysModalTitleSignature').html(stitle); $('#sysModalSignature').modal({show:true,backdrop:'static'}); }); } function _sys_modal_show_footer(stitle,surl,sfooter,dim) { $('.tooltip').hide(); $('#sysModal').removeClass("modal-danger"); $('#btn-modal-close').addClass("btn-primary"); $('#btn-modal-close').removeClass("btn-outline"); _sys_set_modal_dim('sysModal', dim); $('#sysModalContent').load(surl, function(){ var sbtnClose = ''; $('#sysModalFooter').html(sfooter + sbtnClose); $('#sysModalTitle').html(stitle); $('#sysModal').modal({show:true,backdrop:'static'}); $('#sysModal').css('z-index', 3000); } ); } function _sys_nonmodal_show_footer(stitle,surl,sfooter,dim) { $('.tooltip').hide(); $('#sysModal').removeClass("modal-danger"); $('#btn-modal-close').addClass("btn-primary"); $('#btn-modal-close').removeClass("btn-outline"); _sys_set_modal_dim('sysModal', dim); $('#sysModalContent').load(surl, function(){ var sbtnClose = ''; $('#sysModalFooter').html(sfooter + sbtnClose); $('#sysModalTitle').html(stitle); $('#sysModal').modal({show:true}); $('#sysModal').css('z-index', 3000); } ); } function _sys_modal_show_search_footer(stitle,surl,sfooter,dim) { $('.tooltip').hide(); $('#sysModalSearch').removeClass("modal-danger"); $('#btn-modal-close').addClass("btn-primary"); $('#btn-modal-close').removeClass("btn-outline"); _sys_set_modal_dim('sysModalSearch', dim); $('#sysModalSearchContent').load(surl, function(){ var sbtnClose = ''; $('#sysModalSearchFooter').html(sfooter + sbtnClose); $('#sysModalSearchTitle').html(stitle); $('#sysModalSearch').modal({show:true,backdrop:'static'}); } ); } function _sys_modal_hide() { $('.tooltip').hide(); $('#sysModal').modal('hide'); } function _sys_modal_hide_file() { $('.tooltip').hide(); $('#sysModalFile').modal('hide'); } function _sys_modal_hide_signature() { $('.tooltip').hide(); $('#sysModalSignature').modal('hide'); } function _sys_modal_hide_calendar() { $('.tooltip').hide(); $('#sysModalCalendar').modal('hide'); } function _sys_modal_dev() { $('.tooltip').hide(); _sys_modal_show(" Dev Tools","https://app.leti.eu.com/sdk_tools"); } function _sys_ajax_call(surl,sdata,sid) { $('#' + sid).html(''); $('.tooltip').hide(); var jqxhr = $.post(surl,sdata, function(response) { $('#' + sid).html(response); }).fail(function() { if (jqxhr.status == 500) { _sys_modal_show_danger('Errore ' + jqxhr.status,"Pagina: " + surl + "
" + "Codice Errore: " + jqxhr.status + "
" + "Stato: " + jqxhr.statusText + "
" + "Dettagli: " + jqxhr.responseText); }else { _sys_modal_show_danger('Errore ' + jqxhr.status,"Pagina: " + surl + "
" + "Codice Errore: " + jqxhr.status + "
" + "Stato: " + jqxhr.statusText + "
"); } }); } function _sys_ajax_call_callback(surl,sdata,sfunction) { $('.tooltip').hide(); var jqxhr = $.post(surl,sdata, function(response) { eval(sfunction); }).fail(function() { if (jqxhr.status == 500) { _sys_modal_show_danger('Errore ' + jqxhr.status,"Pagina: " + surl + "
" + "Codice Errore: " + jqxhr.status + "
" + "Stato: " + jqxhr.statusText + "
" + "Dettagli: " + jqxhr.responseText); }else { _sys_modal_show_danger('Errore ' + jqxhr.status,"Pagina: " + surl + "
" + "Codice Errore: " + jqxhr.status + "
" + "Stato: " + jqxhr.statusText + "
"); } }); } function _sys_ajax_call_callback_data(surl,sdata,sfunction) { $('.tooltip').hide(); var jqxhr = $.post(surl,sdata, function(response) { var sdataret = jqxhr.responseText; sdataret = sdataret.replace(/(\r\n|\n|\r)/gm,""); eval(sfunction + "('" + sdataret + "');"); }).fail(function() { if (jqxhr.status == 500) { _sys_modal_show_danger('Errore ' + jqxhr.status,"Pagina: " + surl + "
" + "Codice Errore: " + jqxhr.status + "
" + "Stato: " + jqxhr.statusText + "
" + "Dettagli: " + jqxhr.responseText); }else { _sys_modal_show_danger('Errore ' + jqxhr.status,"Pagina: " + surl + "
" + "Codice Errore: " + jqxhr.status + "
" + "Stato: " + jqxhr.statusText + "
"); } }); } function _sys_left(str, n){ if (n <= 0) return ""; else if (n > String(str).length) return str; else return String(str).substring(0,n); } function _sys_right(str, n){ if (n <= 0) return ""; else if (n > String(str).length) return str; else { var iLen = String(str).length; return String(str).substring(iLen, iLen - n); } } function _sys_guid() { var s = []; var hexDigits = "0123456789abcdef"; for (var i = 0; i < 36; i++) { s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1); } s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010 s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01 s[8] = s[13] = s[18] = s[23] = "-"; var uuid = s.join(""); return uuid; } function _date_today(sfieldname) { var d = new Date(); $('#' + sfieldname).val(d.getFullYear() + ('0' + (d.getMonth()+1)).slice(-2) + ('0' + d.getDate()).slice(-2)); } function _date_todaydatetime(sfieldname) { var d = new Date(); $('#' + sfieldname).val(('0' + d.getDate()).slice(-2) + '/' + ('0' + (d.getMonth()+1)).slice(-2) + '/' + d.getFullYear() + ' ' + ('0' + d.getHours()).slice(-2) + ':' + ('0' + d.getMinutes()).slice(-2)+ ':' + ('0' + d.getSeconds()).slice(-2)); } function _sys_is_number(n) { return !isNaN(parseFloat(n)) && isFinite(n); } function _sys_htmlencode(value) { return $("
").text(value).html(); } function _sys_htmldecode(value) { return $("
").html(value).text(); } function _sys_rawurlencode (str) { str = (str+'').toString(); return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/\*/g, '%2A'); } function _sys_skip_confirm() { // Skippa la conferma di salvataggio sys_frm_need_confirm = false; } function _sys_show_search() { _sys_modal_show_search_footer("Cerca","https://app.leti.eu.com/inc/ajax/sys-search.php?s=s",""); } function _sys_validate_email(email) { var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/igm; if (re.test(email)) { return true; } else { return false; } } String.prototype.toHHMM = function () { var sec_num = parseInt(this, 10); // don't forget the second param var hours = Math.floor(sec_num / 3600); var minutes = Math.floor((sec_num - (hours * 3600)) / 60); if (hours < 10) {hours = "0"+hours;} if (minutes < 10) {minutes = "0"+minutes;} return hours+':'+minutes; } Date.prototype.addHours = function(h) { this.setTime(this.getTime() + (h*60*60*1000)); return this; }