// 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.helvetialab.ch/inc/ajax/sys-communication.php"); } function _sys_show_calendar() { $('.tooltip').hide(); _sys_modal_show("Calendario","https://app.helvetialab.ch/inc/ajax/sys-calendar.php"); } function _sys_modal_show_err(stitle,stext,sclass) { $('.tooltip').hide(); $('#sysErrModal').addClass(sclass); $('#sysErrModalTitle').html(stitle); $('#sysErrModalContent').html(stext); $('#btn-modal-close').removeClass("btn-primary"); $('#btn-modal-close').addClass("btn-outline"); $('#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) { $('.tooltip').hide(); _sys_modal_show_footer(stitle,surl,""); } function _sys_nonmodal_show(stitle,surl) { $('.tooltip').hide(); _sys_nonmodal_show_footer(stitle,surl,""); } function _sys_modal_show_file(stitle,surl) { var sfooter = ""; $('.tooltip').hide(); $('#sysModal').removeClass("modal-danger"); $('#btn-modal-close').addClass("btn-primary"); $('#btn-modal-close').removeClass("btn-outline"); $('#sysModalContentFile').load(surl, function(){ var sbtnClose = ''; $('#sysModalFooterFile').html(sfooter + sbtnClose); $('#sysModalTitleFile').html(stitle); $('#sysModalFile').modal({show:true,backdrop:'static'}); }); } function _sys_modal_show_footer(stitle,surl,sfooter) { $('.tooltip').hide(); $('#sysModal').removeClass("modal-danger"); $('#btn-modal-close').addClass("btn-primary"); $('#btn-modal-close').removeClass("btn-outline"); $('#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) { $('.tooltip').hide(); $('#sysModal').removeClass("modal-danger"); $('#btn-modal-close').addClass("btn-primary"); $('#btn-modal-close').removeClass("btn-outline"); $('#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) { $('.tooltip').hide(); $('#sysModalSearch').removeClass("modal-danger"); $('#btn-modal-close').addClass("btn-primary"); $('#btn-modal-close').removeClass("btn-outline"); $('#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_calendar() { $('.tooltip').hide(); $('#sysModalCalendar').modal('hide'); } function _sys_modal_dev() { $('.tooltip').hide(); _sys_modal_show(" Dev Tools","https://app.helvetialab.ch/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.helvetialab.ch/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; } } function _sys_modal_show_post(stitle,surl,data) { $('.tooltip').hide(); _sys_modal_show_footer_post(stitle,surl,"",data); } function _sys_modal_show_footer_post(stitle,surl,sfooter,data) { $('.tooltip').hide(); $('#sysModal').removeClass("modal-danger"); $('#btn-modal-close').addClass("btn-primary"); $('#btn-modal-close').removeClass("btn-outline"); $('#sysModalContent').load(surl,data, function(){ var sbtnClose = ''; $('#sysModalFooter').html(sfooter + sbtnClose); $('#sysModalTitle').html(stitle); $('#sysModal').modal({show:true,backdrop:'static'}); } ); }