function clsCaller() { this.pUrl = ""; this.pFormData = ""; this.pType = "GET"; this.pAsync = true; this.run = function() { var cValues = ""; var me = this; if (me.pFormIDCall=="") { me.pFormIDCall = dataorarioesteso(); } $.ajax({ url: me.pUrl, type: me.pType, async: me.pAsync, data: me.pFormData, success: function(ret, status, xhr) { if (ret!=null) { if (typeof me.onComplete==="function") { me.onComplete(me, ret, status, xhr); } } else { //gestione errore if (typeof me.onError==="function") { me.onError(me, status, xhr); } } }, error: function(xhr, status, error) { if (typeof me.onError==="function") { me.onError(me, status, xhr); } } }); }; } function Caller_Post(azioneapi, data, cb) { var c = new clsCaller(); c.pUrl = "https://amministrazione.motica.it/api/"+azioneapi; c.pFormData = data; c.pType = "POST"; c.pAsync = 1; c.run(); c.onComplete = function(c, res, status, xhr) { if (!Caller_ErrorStatus(res)) { if (cb) cb(res); } }; c.onError = function(c, res, status, xhr) { if (cb) cb(false); }; } function Caller_Get(azioneapi, cb) { var c = new clsCaller(); c.pUrl = "https://amministrazione.motica.it/api/"+azioneapi; c.pType = "GET"; c.pAsync = 1; c.run(); c.onComplete = function(c, res, status, xhr) { if (!Caller_ErrorStatus(res)) { if (cb) cb(res); } }; c.onError = function(c, res, status, xhr) { if (cb) cb(false); }; } function Caller_Delete(azioneapi, cb) { var c = new clsCaller(); c.pUrl = "https://amministrazione.motica.it/api/"+azioneapi; c.pType = "DELETE"; c.pAsync = 1; c.run(); c.onComplete = function(c, res, status, xhr) { if (!Caller_ErrorStatus(res)) { if (cb) cb(res); } }; c.onError = function(c, res, status, xhr) { if (cb) cb(false); }; } function Caller_ErrorStatus(r) { ret = false; if (r.status==401) { $.alert({ title: "Errore sessione", content: '

Permessi non sufficienti o sessione scaduta.
Provare a rifare il login

', buttons: { Ok: function () { document.location.href = "https://amministrazione.motica.it/signin/"; }, } }); ret = true; } return ret; }