From 4802fe7e8d1fe6ea751aecf619b8e826cd2bd684 Mon Sep 17 00:00:00 2001
From: Kilian Saffran
| - - - | - -- - - | -
| année | -début | -fin | -jours | -h/j | -Description | -type | -normal | -except. | -maladie | -|||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
diff --git a/apps/hourtrax/js/app.js b/apps/hourtrax/js/app.js index 33da04b..fba2d01 100644 --- a/apps/hourtrax/js/app.js +++ b/apps/hourtrax/js/app.js @@ -1,16 +1,3 @@ -var eventMethod = window.addEventListener? "addEventListener": "attachEvent"; -var eventer = window[eventMethod]; -var messageEvent = eventMethod === "attachEvent"? "onmessage": "message"; -eventer(messageEvent, function (e) { - // if (e.origin !== 'http://the-trusted-iframe-origin.com') return; - if (e.data === "updatecrechelist" || e.message === "updatecrechelist") { - //alert('Message from iframe just came!'); - // app.getinfo(); - app.loadsites(); - // console.log(e); - } -}); - document.addEventListener("keydown", function(e) { //document.onkeydown = function(e) { // "I" key @@ -44,30 +31,58 @@ document.addEventListener("keydown", function(e) { return false; } + var app = { - currentdb: "0", - info: null, - loadpage: function(page){ - console.log("load Page => " + page); + url: ('https' == document.location.protocol ? 'https' : 'http') + '://' + location.host + '/apps_dks_lu/apps/hourtrax/', + api: ('https' == document.location.protocol ? 'https' : 'http') + '://' + location.host + '/apps_dks_lu/api/', + browser: function(){ + console.log(navigator.userAgent); + var brx = "unknown"; + if (/Safari/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent)){ + brx = "Safari"; + } + if (/Chrome/.test(navigator.userAgent)){ + brx ="Chrome"; + } + if (/Edge/.test(navigator.userAgent)){ + brx ="Edge"; + } + if (/Firefox/.test(navigator.userAgent)){ + brx ="Firefox"; + } + if (/OPR/.test(navigator.userAgent)){ + brx ="Opera"; + } + if (/Trident/.test(navigator.userAgent)){ + brx ="IE"; + } + return brx; + }, + currentdb: null, + info: null, + loadpage: function(page,data = null){ + // console.log("load Page => " + page); // console.log(app); - - var pageurl= location.protocol + '://' + location.host + '/apps_dks_lu/hourtrax/' + page + '?' ; - console.log(app.info); - pageurl += 'db=' + app.info.appconfig.db[app.info.appconfig.currentdb].id; + var da = []; + if (data){ + + for (var i in data){ + da.push(i + "=" + data[i]); + } + } + var pageurl= app.url + page + '?' ; + //console.log(app.info); + pageurl += 'db=' + app.currentdb + ((da.length > 0)?'&' + da.join("&"):''); - + console.log("loadpage: " + pageurl); $('#appframe').attr('src',pageurl); //path += '&data=' + encodeURIComponent(JSON.stringify(data.data)); }, getinfo: function(){ - //if (navigator.platform == "Win32"){ - $.ajax({ + $.ajax({ encoding:"UTF-8", - url:'http://localhost:6060/app/info' , - //crossDomain: true, + url: app.api + 'prefs.cgi?get=auth&app=hourtrax' , success: function (data){ - //dump(data + "\n"); - //console.log("from service:" + JSON.stringify(data)); app.info=data.result; }, error: function(data){ @@ -76,7 +91,6 @@ document.addEventListener("keydown", function(e) { }, async:false }); - //} }, loadprintpreview: function(){ @@ -101,22 +115,48 @@ document.addEventListener("keydown", function(e) { //alert("TODO: load print preview!"); }, loadsites: function(){ + $.ajax({ + encoding:"UTF-8", + url: app.api + 'prefs.cgi?get=auth&app=hourtrax' , + success: function (data){ + console.log(data); + if (data.result.db){ + for (var s in data.result.db){ + //console.log(s); + $("#crechelist").append(''); + //$("#crechelist").append('' + data.result.db[s].name +''); + } + if (app.currentdb == null){ + app.currentdb = data.result.db[0].dbname; + } + } + + + // app.info=data.result; + }, + error: function(data){ + //alert("Error:" + JSON.stringify(data)); + console.log("Error:" + JSON.stringify(data)); + }, + async:false + }); // console.log(app.info); - for (var s in app.info.appconfig.db){ - $("#crechelist").append('' + app.info.appconfig.db[s].name +''); - } + }, - changesite: function(num){ - app.info.appconfig.currendb = num; + changesite: function(){ + var dbname = $("#crechelist :selected").val(); + console.log(dbname); + //app.info.appconfig.currendb = num; + app.currentdb = dbname; $.ajax({ encoding:"UTF-8", - url:'http://localhost:6060/app/preferences?page=service&set=' +encodeURIComponent('{"currentdb":'+ num+'}') , + url:app.api + 'prefs.cgi?page=currentdb&set=' + dbname , //crossDomain: true, success: function (data){ //dump(data + "\n"); //console.log("from service:" + JSON.stringify(data)); - app.info.appconfig=data.result; + //app.info.appconfig=data.result; }, error: function(data){ @@ -124,30 +164,32 @@ document.addEventListener("keydown", function(e) { console.log("Error:" + JSON.stringify(data)); }, async:false - }); - app.loadpage(app.info.appconfig.lastpage); + }); + document.getElementById('appframe').contentWindow.location.reload(true); + //app.loadpage(app.info.appconfig.lastpage); } } //app.getinfo(); $(document).ready(function() { - //app.getinfo(); + //TODO: get userrights + app.getinfo(); app.loadsites(); - if (app.info.appconfig == null){ -// $("#mnubtn_print").prop("disabled",true); -// $("#mnubtn_dashboard").prop("disabled",true); -// for (var i in modules){ -// $("#mnubtn_" + i).prop("disabled",true); -// } - app.loadpage('modules/info/settings.html'); - } else { - if (app.info.appconfig.lastpage){ - app.loadpage(app.info.appconfig.lastpage); - } else { - app.loadpage('modules/dashboard/home.html'); - } - } +// if (app.info.appconfig == null){ +// // $("#mnubtn_print").prop("disabled",true); +// // $("#mnubtn_dashboard").prop("disabled",true); +// // for (var i in modules){ +// // $("#mnubtn_" + i).prop("disabled",true); +// // } +// app.loadpage('modules/info/settings.html'); +// } else { +// if (app.info.appconfig.lastpage){ +// app.loadpage(app.info.appconfig.lastpage); +// } else { +// app.loadpage('modules/dashboard/home.html'); +// } +// } }); @@ -155,17 +197,18 @@ document.addEventListener("keydown", function(e) { $("#appframe").on('load', function(){ console.log($("#appframe").attr("src")); var src = $("#appframe").attr("src").replace(/\\/g,'/'); - src = src.substring(src.indexOf('/app/') + 5); + src = src.substring(src.indexOf('/creorga/') + 5); src = src.substring(0,src.indexOf('?')); - console.log(src); + console.log(src); + console.log(app.api); $.ajax({ encoding:"UTF-8", - url:'http://localhost:6060/app/preferences?page=service&set=' +encodeURIComponent('{"lastpage":"'+ src+'"}') , + url:app.api +'prefs.cgi?page=service&set=' +encodeURIComponent('{"lastpage":"'+ src+'"}') , //crossDomain: true, success: function (data){ - - console.log(data); - app.info.appconfig=data.result; + //console.log("appdata"); + //console.log(data); + //app.info.appconfig=data.result; }, error: function(data){ diff --git a/apps/hourtrax/js/app.old.js b/apps/hourtrax/js/app.old.js new file mode 100644 index 0000000..33da04b --- /dev/null +++ b/apps/hourtrax/js/app.old.js @@ -0,0 +1,178 @@ +var eventMethod = window.addEventListener? "addEventListener": "attachEvent"; +var eventer = window[eventMethod]; +var messageEvent = eventMethod === "attachEvent"? "onmessage": "message"; +eventer(messageEvent, function (e) { + // if (e.origin !== 'http://the-trusted-iframe-origin.com') return; + if (e.data === "updatecrechelist" || e.message === "updatecrechelist") { + //alert('Message from iframe just came!'); + // app.getinfo(); + app.loadsites(); + // console.log(e); + } +}); + +document.addEventListener("keydown", function(e) { + //document.onkeydown = function(e) { + // "I" key + if (e.ctrlKey && e.shiftKey && e.keyCode == 73) { + disabledEvent(e); + } + // "J" key + if (e.ctrlKey && e.shiftKey && e.keyCode == 74) { + disabledEvent(e); + } + // "S" key + macOS + if (e.keyCode == 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) { + disabledEvent(e); + } + // "U" key + if (e.ctrlKey && e.keyCode == 85) { + disabledEvent(e); + } + // "F12" key + if (event.keyCode == 123) { + disabledEvent(e); + } + }, false); + function disabledEvent(e){ + if (e.stopPropagation){ + e.stopPropagation(); + } else if (window.event){ + window.event.cancelBubble = true; + } + e.preventDefault(); + return false; + } + + var app = { + currentdb: "0", + info: null, + loadpage: function(page){ + console.log("load Page => " + page); + // console.log(app); + + var pageurl= location.protocol + '://' + location.host + '/apps_dks_lu/hourtrax/' + page + '?' ; + console.log(app.info); + pageurl += 'db=' + app.info.appconfig.db[app.info.appconfig.currentdb].id; + + + $('#appframe').attr('src',pageurl); + //path += '&data=' + encodeURIComponent(JSON.stringify(data.data)); + }, + getinfo: function(){ + //if (navigator.platform == "Win32"){ + $.ajax({ + encoding:"UTF-8", + url:'http://localhost:6060/app/info' , + //crossDomain: true, + success: function (data){ + //dump(data + "\n"); + //console.log("from service:" + JSON.stringify(data)); + app.info=data.result; + }, + error: function(data){ + //alert("Error:" + JSON.stringify(data)); + console.log("Error:" + JSON.stringify(data)); + }, + async:false + }); + //} + + }, + loadprintpreview: function(){ + var myprinturl = $('#appframe').attr('src'); + var myprinturl = myprinturl.replace(/\\/g,'/'); + var src = myprinturl.substring(0,myprinturl.indexOf('?')); + var moduledir = src.substring(src.indexOf('app')+3,src.lastIndexOf('/')); + var reportfilepath = src.substring(0,src.lastIndexOf('/')); + + var reportfile = 'report_' +src.substring(src.lastIndexOf('/') + 1); + var params = myprinturl.substring(myprinturl.indexOf('?')+1) + console.log("Current URL: " + myprinturl); + console.log("File: " + src); + console.log("ModuleDir: " + moduledir); + console.log("New File: " + reportfile); + console.log("Params: " + params); + console.log("Printfile: " + reportfilepath + '/' + reportfile +'?'+ encodeURIComponent(params)); + //?file='+ encodeURIComponent(reportfilepath + '/' + reportfile +'?'+ params) + //let modal = window.open('pdfjs/viewer.html?file=' + encodeURIComponent('../../' +moduledir + '/' + reportfile)); + let modal = window.open(reportfilepath + '/' + reportfile +'?'+ params); + //modal.document.write('
'); + //alert("TODO: load print preview!"); + }, + loadsites: function(){ + // console.log(app.info); + for (var s in app.info.appconfig.db){ + $("#crechelist").append('' + app.info.appconfig.db[s].name +''); + } + + }, + changesite: function(num){ + app.info.appconfig.currendb = num; + $.ajax({ + encoding:"UTF-8", + url:'http://localhost:6060/app/preferences?page=service&set=' +encodeURIComponent('{"currentdb":'+ num+'}') , + //crossDomain: true, + success: function (data){ + //dump(data + "\n"); + //console.log("from service:" + JSON.stringify(data)); + app.info.appconfig=data.result; + + }, + error: function(data){ + //alert("Error:" + JSON.stringify(data)); + console.log("Error:" + JSON.stringify(data)); + }, + async:false + }); + app.loadpage(app.info.appconfig.lastpage); + } + + + } + //app.getinfo(); + $(document).ready(function() { + //app.getinfo(); + app.loadsites(); + if (app.info.appconfig == null){ +// $("#mnubtn_print").prop("disabled",true); +// $("#mnubtn_dashboard").prop("disabled",true); +// for (var i in modules){ +// $("#mnubtn_" + i).prop("disabled",true); +// } + app.loadpage('modules/info/settings.html'); + } else { + if (app.info.appconfig.lastpage){ + app.loadpage(app.info.appconfig.lastpage); + } else { + app.loadpage('modules/dashboard/home.html'); + } + } + + + }); + + $("#appframe").on('load', function(){ + console.log($("#appframe").attr("src")); + var src = $("#appframe").attr("src").replace(/\\/g,'/'); + src = src.substring(src.indexOf('/app/') + 5); + src = src.substring(0,src.indexOf('?')); + console.log(src); + $.ajax({ + encoding:"UTF-8", + url:'http://localhost:6060/app/preferences?page=service&set=' +encodeURIComponent('{"lastpage":"'+ src+'"}') , + //crossDomain: true, + success: function (data){ + + console.log(data); + app.info.appconfig=data.result; + + }, + error: function(data){ + //alert("Error:" + JSON.stringify(data)); + console.log("Error:" + JSON.stringify(data)); + }, + async:false + }); + }) + \ No newline at end of file diff --git a/apps/hourtrax/js/webdatabase.js b/apps/hourtrax/js/webdatabase.js index 07f4815..c7f1a7c 100644 --- a/apps/hourtrax/js/webdatabase.js +++ b/apps/hourtrax/js/webdatabase.js @@ -1,15 +1,18 @@ var appdb = { - dbfile: null, - url: location.protocol + '://' + location.host + '/creorga_lu/api/sqlite.cgi?', + dbfile: parent.app.currentdb, + url: ('https' == document.location.protocol ? 'https' : 'http') + '://' + location.host + '/apps_dks_lu/api/sqlite.cgi?', dbquery: function(sQuery){ var type='querysorted'; - var result= {sqldata:[]}; + var result= {sqldata:[]}; + //console.log(sQuery); //console.log(this.url + 'db=' + this.dbfile + '&type=' + type + '&sql=' +encodeURIComponent(sQuery)); //dump(this.url + 'db=' + this.dbfile + '&type=' + type + '&sql=' +encodeURIComponent(sQuery) + "\n"); $.ajax({ - encoding:"UTF-8", - url:this.url + 'db=' + this.dbfile + '&type=' + type + '&sql=' +encodeURIComponent(sQuery) , - crossDomain: true, + encoding:"UTF-8", + method: "POST", + url:appdb.url, + data: 'db=' + appdb.dbfile + '&type=' + type + '&sql=' +encodeURIComponent(sQuery), + //crossDomain: true, success: function (data){ //dump(data + "\n"); result=data.result; @@ -25,14 +28,17 @@ var appdb = { dbqueryarray: function(sQuery){ var type='queryarray'; var result= {sqldata:[]}; - //console.log(this.url + 'db=' + this.dbfile + '&type=' + type + '&sql=' +encodeURIComponent(sQuery)); + //console.log(appdb.url + 'db=' + appdb.dbfile + '&type=' + type + '&sql=' +encodeURIComponent(sQuery)); //alert(this.url + 'db=' + this.dbfile + '&type=' + type + '&sql=' +encodeURIComponent(sQuery) + "\n"); $.ajax({ encoding:"UTF-8", - url:this.url + 'db=' + this.dbfile + '&type=' + type + '&sql=' +encodeURIComponent(sQuery) , - crossDomain: true, + url:appdb.url , + method: "POST", + data: 'db=' + appdb.dbfile + '&type=' + type + '&sql=' +encodeURIComponent(sQuery), + //crossDomain: true, success: function (data){ - result=data.result; + + result=data.result; }, error: function(data){ alert("Error:" + JSON.stringify(data)); @@ -46,11 +52,12 @@ var appdb = { var type='exec'; var result= {sqldata:[]}; //dump(this.url + 'db=' + this.dbfile + '&type=' + type + '&sql=' +encodeURIComponent(sQuery) + "\n"); - console.log(this.url + 'db=' + this.dbfile + '&type=' + type + '&sql=' +encodeURIComponent(sQuery) ); + //console.log(appdb.url + 'db=' + appdb.dbfile + '&type=' + type + '&sql=' +encodeURIComponent(sQuery) ); $.ajax({ encoding:"UTF-8", - url:this.url + 'db=' + this.dbfile + '&type=' + type + '&sql=' +encodeURIComponent(sQuery) , - crossDomain: true, + method: "POST", + url:appdb.url, + data: 'db=' + appdb.dbfile + '&type=' + type + '&sql=' +encodeURIComponent(sQuery), success: function (data){ result=data.result; }, diff --git a/apps/hourtrax/js/webpreferences.js b/apps/hourtrax/js/webpreferences.js index 1effacd..630618e 100644 --- a/apps/hourtrax/js/webpreferences.js +++ b/apps/hourtrax/js/webpreferences.js @@ -1,36 +1,38 @@ -var globalreq = { - send_request: function(data){ +// var globalreq = { +// send_request: function(data){ - if (data.page){ - if (data.data){ - console.log(window.location.pathname); - var page = data.page.substring(data.page.lastIndexOf("/") + 1); - page = page.replace(/\.html/,''); - console.log(page); - $.ajax({ - encoding:"UTF-8", - url: location.protocol + '://' + location.host + '/creorga_lu/api/prefs.cgi??page=' + page + '&set=' +encodeURIComponent('{"data":' + JSON.stringify(data.data) +'}') , - crossDomain: true, - success: function (data){ - var result=data.result; - }, - error: function(data){ - alert("Error:" + JSON.stringify(data)); - console.log("Error:" + JSON.stringify(data)); - }, - async:false - }); - } +// if (data.page){ +// if (data.data){ +// console.log(window.location.pathname); +// var page = data.page.substring(data.page.lastIndexOf("/") + 1); +// page = page.replace(/\.html/,''); +// console.log(page); +// $.ajax({ +// encoding:"UTF-8", +// url: location.protocol + '://' + location.host + '/apps_dks_lu/api/api/prefs.cgi?page=' + page + '&set=' +encodeURIComponent('{"data":' + JSON.stringify(data.data) +'}') , +// crossDomain: true, +// success: function (data){ +// var result=data.result; +// }, +// error: function(data){ +// alert("Error:" + JSON.stringify(data)); +// console.log("Error:" + JSON.stringify(data)); +// }, +// async:false +// }); +// } - var path = location.protocol + '://' + location.host + '/creorga_lu/'; - path = path + data.page + '?'; - path += 'db=' + apppref.curcfg.db; - window.location = path; - } - } -} +// var path = location.protocol + '://' + location.host + '/creorga_lu/'; +// path = path + data.page + '?'; +// path += 'db=' + apppref.curcfg.db; +// window.location = path; +// } +// } +// } var apppref ={ + url: ('https' == document.location.protocol ? 'https' : 'http') + '://' + location.host + '/apps_dks_lu/creorga/', + api: ('https' == document.location.protocol ? 'https' : 'http') + '://' + '//' + location.host + '/apps_dks_lu/api/', curcfg: null, getSearchParams: function (k){ //alert(location.href); @@ -62,19 +64,22 @@ var apppref ={ // appdb.url = "http://localhost:6060/sqlite?"; $("#current_site").html(decodeURI(this.curcfg.sitename)); }, - setpreference:function(section,key,value){ - if (!apppref.curcfg.pageconfig[section]){ - apppref.curcfg.pageconfig[section] = {}; - } - apppref.curcfg.pageconfig[section][key] = value; + setpreference:function(key,value){ + // if (!apppref.curcfg.pageconfig[section]){ + // apppref.curcfg.pageconfig[section] = {}; + // } + // apppref.curcfg.pageconfig[section][key] = value; - var page = location.pathname.substring(location.pathname.lastIndexOf("/")); - page = page.replace(/\.html/,''); + + //var page = location.pathname.substring(location.pathname.lastIndexOf("/")); + //page = page.replace(/\.html/,''); + $.ajax({ encoding:"UTF-8", - url: location.protocol + '://' + location.host + '/creorga_lu/api/prefs.cgi?page=' + page + '&set=' +encodeURIComponent(JSON.stringify(apppref.curcfg.pageconfig)) , - crossDomain: true, + url: apppref.api + 'prefs.cgi?page=' + key + '&set=' +encodeURIComponent(JSON.stringify(value)) , + //crossDomain: true, success: function (data){ + var result=data.result; }, error: function(data){ @@ -84,16 +89,18 @@ var apppref ={ }); }, getpreference: function(key){ - apppref.curcfg['pageconfig'] = {}; + console.log("getpref:" + key); + var retdata = null; $.ajax({ encoding:"UTF-8", - url: location.protocol + '://' + location.host + '/creorga_lu/api/prefs.cgi?page=' + key , - crossDomain: true, - success: function (data){ - if (data.result){ - apppref.curcfg.pageconfig = data.result; - } + url: apppref.api + 'prefs.cgi?get=' + key , + success: function (data){ + if (!data.result){ + retdata = {}; + }else { + retdata = data.result; + } }, error: function(data){ alert("Error:" + JSON.stringify(data)); @@ -101,13 +108,13 @@ var apppref ={ }, async:false }); - + return retdata; }, getforeignpreference: function(key){ var ret = null; $.ajax({ encoding:"UTF-8", - url: location.protocol + '://' + location.host + '/creorga_lu/api/prefs.cgi?page=' + key , + url: app.api + 'prefs.cgi?get=' + key , crossDomain: true, success: function (data){ if (data.result){ diff --git a/apps/hourtrax/modules/calendar/calactivity.html b/apps/hourtrax/modules/calendar/calorganisation.html similarity index 100% rename from apps/hourtrax/modules/calendar/calactivity.html rename to apps/hourtrax/modules/calendar/calorganisation.html diff --git a/apps/creorga/modules/logbook/logstaff.html b/apps/hourtrax/modules/company/companylist.html similarity index 100% rename from apps/creorga/modules/logbook/logstaff.html rename to apps/hourtrax/modules/company/companylist.html diff --git a/apps/hourtrax/modules/staff/coworker_basic.html b/apps/hourtrax/modules/staff/coworker_basic.html deleted file mode 100644 index 1c77190..0000000 --- a/apps/hourtrax/modules/staff/coworker_basic.html +++ /dev/null @@ -1,302 +0,0 @@ - - - -
- - -
- - - - - - - - - - - - - - - -
-