From: Kilian Saffran Date: Mon, 6 May 2019 07:33:02 +0000 (+0200) Subject: creorga website corrections X-Git-Url: http://cloud.dks.lu/git/?a=commitdiff_plain;h=047d5047b8e75473e33a128cd1057f987d531036;p=dks_lu.git creorga website corrections --- diff --git a/TODO/modules_todo/staff/coworker.html b/TODO/modules_todo/staff/coworker.html deleted file mode 100644 index 50d07bc..0000000 --- a/TODO/modules_todo/staff/coworker.html +++ /dev/null @@ -1,619 +0,0 @@ - - - - - - - Employé(e) - - - - - - - - - - - - - -
-
- - - - - - - - - - -
-
-
- - - -
- -
- -
- -
- - - -
- -
- -
-
- - - -
-
- -
-
-
- -
- -
- -
- -
-
- -
- -
- - -
- -
- - -
h
-
-
- -
- - -
h
-
-
- -
- -
-
-
- -
-
- -
- -
(Min: 4 charatères)
-
-
- -
- -
-
-
- - -
- -
-
- -
- -
- -
- - - - -
-
-
-
- -
- -
- -
- - -
- - h -
- -
-
- - - - - - - - - - - - - - - - - - - -
annéedébutfinjoursh/jDescriptiontypenormalexcept.maladie
- - -
- -
-
-
- - - - - - - - - - - - - - - - - - - - - - diff --git a/TODO/modules_todo/staff/js/coworker.js b/TODO/modules_todo/staff/js/coworker.js deleted file mode 100644 index 9d005d8..0000000 --- a/TODO/modules_todo/staff/js/coworker.js +++ /dev/null @@ -1,954 +0,0 @@ -//Source-code licensed under EUPL v1.2 ( Copyright 2019 By DKS s.à r.l. - Kilian Saffran - Luxembourg ) -var pconfig = {}; -var delplan = null; -var delvacation = null; -var wh= window.innerHeight -320; -var curdatediff = null; -var redate = /\d\d.\d\d.\d\d\d\d/; -var curfreq ={}; -var maxdayhours = null; -var maxhalfdayhours = null; -var tblvac = null; -//var lictype = parent.apppref.getpreference("support.lictype"); - -function initdata() { - load_helpers(); - var sp = getSearchParams(); - pconfig = parent.apppref.getpreference("coworker"); - if (sp.uuid){ - pconfig.uuid = sp.uuid; - } - if (pconfig == null) { - pconfig = {}; - } - parent.appdb.dbexec("update vacancycalendar set vacyear=strftime('%Y',datefrom) where vacyear is null;"); - //"get CoWorker cfg:" +JSON.stringify(pconfig) + "\n"); - if (!pconfig.year) { - pconfig.year=new Date().getFullYear(); - } - if (!pconfig.printlayout) { - pconfig.printlayout = 'list'; - parent.apppref.setpreference("coworker",pconfig); - } - var cdatasql = "SELECT jobtitle, prename, surname, address, zip, city, country, strftime('%d.%m.%Y',entrydate) as entrydate, strftime('%d.%m.%Y',exitdate) as exitdate, iban, bic, accountname, phone, email, uuid,color,weekhours,maxdayhours,case when password is not null and length(password) > 3 then 1 else 0 end as passwordset FROM staff where uuid='" + pconfig.uuid + "';"; - var cdata = parent.appdb.dbquery(cdatasql); - cdata = cdata.sqldata[0]; - for (var ci in cdata) { - if (document.getElementById("staff_" + ci)) { - document.getElementById("staff_" + ci).setAttribute('value', cdata[ci]); - } - - } - - // var crdata = parent.appdb.dbquery("select stafflist from creche;"); - // if ((crdata) && (crdata.sqldata[0].stafflist == "1")){ - // $("#pwddata").hide(); - // } - // if (cdata) { - // set_infoheader(cdata.prename + " " + cdata.surname); - // } - $('#staff_color').minicolors({theme:'bootstrap'}); - set_selectyears(); - //load_staff_selection('staffuuid'); - - if (pconfig && pconfig.activetab) { - $('a[href="#'+pconfig.activetab+'"]').tab('show'); - }else{ - $('a[href="#vacancy"]').tab('show'); - pconfig.activetab = 'vacancy'; - } - -// if (pconfig && pconfig.vacancyunit){ -// //dump("has vacancy unit:" + pconfig.vacancyunit + "\n"); -// $('#vacancy_unit').val(pconfig.vacancyunit); -// }else { - pconfig.vacancyunit = "hours"; -// $('#vacancy_unit').val("days"); -// } - - - -} - -$('#frmeditvacancy #vacdatefrom').on("blur",function (e) { - var ok = true; - if ($('#frmeditvacancy #vacdatefrom').val().match(redate)) { - $('#btn_save_vacancy').removeAttr("disabled"); - }else { - ok = false; - $('#btn_save_vacancy').attr("disabled","1"); - } - if ((ok == true) && ($('#frmeditvacancy #vacdateto').val() != '')) { - var tmpdt1 = encodeparam($('#frmeditvacancy #vacdatefrom').val(),'date'); - var nd = new Date(tmpdt1.replace(/'/g,'')); - var xd = new Date(nd.getFullYear(),nd.getMonth(),nd.getDate() + curdatediff); - $('#frmeditvacancy #vacdateto').val(xd.toISOString().substring(0,10)); - var tmpdt2 = encodeparam($('#frmeditvacancy #vacdateto').val(),'date'); - if (tmpdt1 > tmpdt2) { - $('#btn_save_vacancy').attr("disabled","1"); - } else { - $('#btn_save_vacancy').removeAttr("disabled"); - } - - } -}); -$('#frmeditvacancy #vacdateto').on("blur",function (e) { - var ok = true; - if ($('#frmeditvacancy #vacdateto').val().match(redate)) { - $('#btn_save_vacancy').removeAttr("disabled"); - }else { - ok = false; - $('#btn_save_vacancy').attr("disabled","1"); - } - curdatediff=daysBetween(new Date(encodeparam($('#frmeditvacancy #vacdatefrom').val(),'date').replace(/'/g,'')),new Date(encodeparam($('#frmeditvacancy #vacdateto').val(),'date').replace(/'/g,''))); - if ((ok == true) && ($('#frmeditvacancy #vacdateto').val() != '')) { - var tmpdt1 = encodeparam($('#frmeditvacancy #vacdatefrom').val(),'date'); - var tmpdt2 = encodeparam($('#frmeditvacancy #vacdateto').val(),'date'); - if (tmpdt1 > tmpdt2) { - $('#btn_save_vacancy').attr("disabled","1"); - } else { - $('#btn_save_vacancy').removeAttr("disabled"); - } - - } -}); -$('#dailyduration').on('change',function(e){ - if ($('#dailyduration').val() == "1.0"){ - $('#frmeditvacancy #hours').val(maxdayhours); - } - if ($('#dailyduration').val() == "0.4"){ - $('#frmeditvacancy #hours').val(maxhalfdayhours); - } -}); -$('#staff_color').on('change',function(e){ - saveonfocusout('staff_color'); -}); - -$("#weekly_byday :input").change(function() { - if (this.checked) { - this.setAttribute("checked",true); - }else { - this.removeAttribute("checked"); - } - -}); -$("#monthly_bydaypos :input").change(function() { - - if (this.checked) { - this.setAttribute("checked",true); - }else { - this.removeAttribute("checked"); - } - -}); -$("#monthly_bydaywday :input").change(function() { - - if (this.checked) { - this.setAttribute("checked",true); - }else { - this.removeAttribute("checked"); - } - -}); -$("#monthly_bymonthday :input").change(function() { - - if (this.checked) { - this.setAttribute("checked",true); - }else { - this.removeAttribute("checked"); - } - -}); -$("#monthly_by :input").change(function() { - var xd = this.id.split("_"); - curfreq.freqtype=xd[2]; - - this.setAttribute("checked",true); - - $('#freq_monthly_byday').hide(); - $('#freq_monthly_bymonthday').hide(); - $('#pnl_monthly_byday').removeAttr("checked"); - $('#pnl_monthly_bymonthday').removeAttr("checked"); - - $('#freq_' + this.value).show(); - -}); - -$('#frmeditevent #datefrom').on("blur",function (e) { - var ok = true; - if ($('#frmeditevent #datefrom').val().match(redate)) { - $('#btn_save_event').removeAttr("disabled"); - }else { - ok = false; - $('#btn_save_event').attr("disabled","1"); - } - if ((ok == true) && ($('#frmeditevent #dateto').val() != '')) { - var tmpdt1 = encodeparam($('#frmeditevent #datefrom').val(),'date'); - var tmpdt2 = encodeparam($('#frmeditevent #dateto').val(),'date'); - if (tmpdt1 >= tmpdt2) { - $('#btn_save_event').attr("disabled","1"); - } else { - $('#btn_save_event').removeAttr("disabled"); - } - - } -}); -$('#frmeditevent #dateto').on("blur",function (e) { - var ok = true; - if ($('#frmeditevent #dateto').val().match(redate)) { - $('#btn_save_event').removeAttr("disabled"); - }else { - ok = false; - $('#btn_save_event').attr("disabled","1"); - } - if ((ok == true) && ($('#frmeditevent #dateto').val() != '')) { - var tmpdt1 = encodeparam($('#frmeditevent #datefrom').val(),'date'); - var tmpdt2 = encodeparam($('#frmeditevent #dateto').val(),'date'); - - if (tmpdt1 >= tmpdt2) { - $('#btn_save_event').attr("disabled","1"); - } else { - $('#btn_save_event').removeAttr("disabled"); - } - - } -}); - -$('.selyear').on( "change", function(e){ - e.preventDefault(); - - $(".selyear").val($(this).val()); - pconfig.year = $(this).val(); - parent.apppref.setpreference("coworker",pconfig); - if ($(this).attr('id') == "year_organisation") { - load_event_data(); - }else if ($(this).attr('id') == "year_vacancy") { - load_table_vacancy(); - } -}); - -$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) { - var tn = e.target.toString(); - pconfig.activetab = tn.substring(tn.lastIndexOf("#")+1); - - parent.apppref.setpreference("coworker",pconfig); - if (pconfig.activetab == 'activity') { - load_event_data(); - } - if (pconfig.activetab == 'vacancy') { - load_table_vacancy(); - } - }); - -function load_event_data() { - //dump("Load event Table!\n"); - var where = new Array(); - - where.push(" st.uuid in ('"+ pconfig.uuid + "')"); - - $("div.panel-daybody").html(""); - var sql = "SELECT cal.uuid, cal.datefrom, cal.dateto, '
' || strftime('%Y%m%d',cal.datefrom) ||'
' || strftime('%d.%m.%Y',cal.datefrom) AS tbldatefrom ,strftime('%Y%m%d',cal.datefrom) AS strdatefrom, strftime('%Y%m%d',cal.dateto) AS strdateto,cal.timefrom, cal.timeto, cal.description, cal.location, cal.color, cal.freq, '[\"' || GROUP_CONCAT(sp.staffuuid,'\",\"') || '\"]' as staffuuid, GROUP_CONCAT(coalesce(st.surname,'') || ' ' || coalesce(st.prename,''), '
' ) as staffnames ,'[\"' || GROUP_CONCAT(st.color,'\",\"') || '\"]' as staffcolors from eventcalendar cal " +" join staffplanning sp on (cal.uuid=sp.eventcalendaruuid " + " AND sp.staffuuid in ('"+ pconfig.uuid +"')) left join staff st on (sp.staffuuid=st.uuid) "+ - " where (cal.datefrom between '" + $('#year_organisation').val() + "-01-01' and '" + $('#year_organisation').val() + "-12-31' and (cal.dateto >= '" + $('#year_organisation').val() + "-01-01' or cal.dateto is null)) or (cal.dateto between '" + $('#year_organisation').val() + "-01-01' and '" + $('#year_organisation').val() + "-12-31' and cal.datefrom < '" + $('#year_organisation').val() + "-01-01') or ((cal.datefrom <= '" + $('#year_organisation').val() + "-01-01') and ((cal.dateto >= '" + $('#year_organisation').val() + "-12-31') or cal.dateto is null)) "+ ((where.length > 0)?" AND (" + where.join(" or ") + ")":"")+" group by cal.uuid order by cal.datefrom,cal.dateto;"; - - var caldata = parent.appdb.dbquery(sql); - - caldata = caldata.sqldata; - - var headerdata = getlabels("act,datefrom,hours,recurrance"); - $("#tbl_activity").html(""); - - var hrow = headerdata; - var tdclass= new Array(); - var tblheader = ''; - - for (var h=0;h'+ headerdata[h].title+''; - } - tblheader += ''; - - $("#tbl_activity").append("" + tblheader + ""); - $("#tbl_activity").append(""); - var tblbody = []; - for (var c in caldata) { - var tblrow = ""; - tblrow += ''; - //tblrow += ""+caldata[c].description+"" + caldata[c].description + ""; - //tblrow += "" + caldata[c].staffnames + ""; - tblrow += "" + caldata[c].tbldatefrom + ""; - tblrow += "" + caldata[c].timefrom + "- " + caldata[c].timeto + ""; - - var freq2 = caldata[c].freq; - if (freq2 != '') { - - freq2 += ';DTSTART='+caldata[c].strdatefrom + 'T000000Z'; - if (caldata[c].dateto != ''){ - freq2 += ';UNTIL='+caldata[c].strdateto + 'T000000Z'; - } - } - - try { - - var rule2 = RRule.fromString(freq2); - - - tblrow += "" + rule2.toText() + ""; - - } catch (ex){ - //"ERROR! loading data!" + ex + " FREQ:" + freq2 + "\n"); - } - tblrow += ""; - tblbody.push(tblrow); - } - - //load table - $("#tbl_activity").append(tblbody.join('')); - $("#tbl_activity").append(""); - - $("#tbl_activity").bootstrapTable({ - locale: 'fr-FR', - pagination: false, - search: false, - height: wh, - toolbar: "#mnuact" - }); - - -} - -function load_table_vacancy() { - tblvac =null; - var yearvacanysql = "select hours from staffvacancydays where staffuuid='"+ pconfig.uuid+"' and vacancyyear='"+ $("#year_vacancy").val() +"';"; - var yearvac = parent.appdb.dbquery(yearvacanysql); - var nvyear = ""; - if ((yearvac) && (yearvac.sqldata)){ - nvyear = yearvac.sqldata[0].hours; - } - $("#vacancyyeartotal").val(nvyear); - var vacdatasql = "SELECT '" + - "' AS action," + "vacyear," + - "strftime('%d.%m.%Y', datefrom) as datefrom,strftime('%d.%m.%Y', dateto) as dateto,printf(\"%.2f\",dayhours) as dayhours,totaldays,description," + - "case when type = 0 and accepted != '1' then printf(\"%.2f\", hours) else '' end as thnormalnv," + - "case when type = 1 and accepted != '1' then printf(\"%.2f\", hours) else '' end as thextranv," + - "case when type =-1 and accepted != '1' then printf(\"%.2f\", hours) else '' end as thillnv," + - "case when type = 0 and accepted = '1' then printf(\"%.2f\", hours) else '' end as thnormalval," + - "case when type = 1 and accepted = '1' then printf(\"%.2f\", hours) else '' end as thextraval," + - "case when type =-1 and accepted = '1' then printf(\"%.2f\", hours) else '' end as thillval," + - "case when type = 0 then 'normal' when type = 1 then 'exceptionnel' when type =-1 then 'maladie' end as vacancytype" + - " FROM (" + - "select uuid, vacyear, datefrom, dateto, type, description, accepted, (days-day_to_much-vdays) * (case when hours < maxdayhours then hours when hours > maxdayhours then maxdayhours else hours end ) as hours, "+ - "case when hours < maxdayhours then hours when hours > maxdayhours then maxdayhours else hours end as dayhours,days-day_to_much-vdays as totaldays " + - " from (" + - "select vc.uuid,vc.vacyear,vc.datefrom,vc.dateto,vc.type,vc.description,vc.accepted," + - "((strftime('%s',vc.dateto) - strftime('%s',vc.datefrom)) /84600) + 1 as days," + - "((((strftime('%s',vc.dateto) - strftime('%s',vc.datefrom)) /84600) + 1) / 7) * (7 - (st.weekhours / st.maxdayhours)) as day_to_much," + - "(select count(v.vacancydate) from vacancy v where v.vacancydateto is null and strftime('%s',v.vacancydate) not in ('0','6') and v.vacancydate between vc.datefrom and vc.dateto) as vdays,st.weekhours,st.weekhours / maxdayhours as days_per_week,vc.timefrom,vc.timeto,st.maxdayhours, " + - "cast(cast(strftime(\"%s\",vc.timeto) as int)- cast(strftime(\"%s\",vc.timefrom) as int) as real)/3600 as hours " + - "from vacancycalendar vc join staff st on (vc.staffuuid=st.uuid) where vc.staffuuid='"+ pconfig.uuid+"' and vc.vacyear=" + pconfig.year+"));"; - -//jsdump("XXSQL:" + vacdatasql + "\n"); -var vacdata = parent.appdb.dbquery(vacdatasql); - var sums = { normal:0,except:0,ill:0,normal_ok:0,except_ok:0,ill_ok:0}; - - $("#tbl_vacancy > tbody").html(""); - - for (var i in vacdata.sqldata){ - var row = vacdata.sqldata[i]; - // sums.all = sums.all + ((row.dayhours != '')?parseFloat(row.dayhours):0.00); - sums.normal = sums.normal + ((row.thnormalnv != '')?parseFloat(row.thnormalnv):0.00); - sums.except = sums.except + ((row.thextranv != '')?parseFloat(row.thextranv):0.00); - sums.ill = sums.ill + ((row.thillnv != '')?parseFloat(row.thillnv):0.00); - sums.normal_ok = sums.normal_ok + ((row.thnormalval != '')?parseFloat(row.thnormalval):0.00); - sums.except_ok = sums.except_ok + ((row.thextraval != '')?parseFloat(row.thextraval):0.00); - sums.ill_ok = sums.ill_ok + ((row.thillval != '')?parseFloat(row.thillval):0.00); - var tr = ''; - tr += '' + row.action + ''; - tr += '' + row.vacyear + ''; - tr += '' + row.datefrom + ''; - tr += '' + row.dateto + ''; - tr += '' + row.totaldays + ''; - tr += '' + row.dayhours + ''; - tr += '' + row.description + ''; - tr += '' + row.vacancytype + ''; - tr += '' + row.thnormalnv + ''; - tr += '' + row.thnormalval + ''; - tr += '' + row.thextranv + ''; - tr += '' + row.thextraval + ''; - tr += '' + row.thillnv + ''; - tr += '' + row.thillval + ''; - tr += ''; - $("#tbl_vacancy > tbody").append(tr); - - } - var tfoot = "" - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' - + '' + sums.normal.toFixed(2) + '' - + '' + sums.normal_ok.toFixed(2) + '' - + '' + sums.except.toFixed(2) + '' - + '' + sums.except_ok.toFixed(2) + '' - + '' + sums.ill.toFixed(2) + '' - + '' + sums.ill_ok.toFixed(2) + '' - +""; - $("#tbl_vacancy > tfoot").html(tfoot); - - $("#tbl_vacancy").bootstrapTable({ - locale: 'fr-FR', - pagination: false, - search: false, - toolbar: "#mnuvac" - }); - - - -} - -function dlg_vacancy(uuid, type) { - //select weekhours/5 = max daily hours - maxdayhours = (parseFloat($("#staff_weekhours").val())/5).toFixed(2); - maxhalfdayhours = (maxdayhours/2).toFixed(2); - var evdata = { - uuid: 0, - description: '', - vacdatefrom:new Date().toISOString().substring(0,10), - vacdateto:new Date().toISOString().substring(0,10), - staffuuid:[pconfig.uuid], - timefrom: '00:00', - hours: maxdayhours, - type:'0', - //dailyduration:'1.0', - //hourmax: whr - }; - - if (type == 'upd') { - var evsql = "select uuid,vacdatefrom,vacdateto,timefrom,description,staffuuid,case when hours = '0.00' then '" + maxdayhours +"' else hours end as hours,accepted from (SELECT uuid, strftime(\"%d.%m.%Y\",datefrom) as vacdatefrom, strftime(\"%d.%m.%Y\",dateto) as vacdateto, timefrom, description, '"+pconfig.uuid+"' as staffuuid,type, printf(\"%.2f\",cast((cast(strftime(\"%s\",timeto) as int)- cast(strftime(\"%s\",timefrom) as int))/3600 as real)) as hours,accepted FROM vacancycalendar where uuid='" + uuid.uuid + "');"; - //var evsql = "SELECT uuid, strftime(\"%d.%m.%Y\",datefrom) as vacdatefrom, strftime(\"%d.%m.%Y\",dateto) as vacdateto, timefrom, description, '"+pconfig.uuid+"' as staffuuid,type, case when timefrom!=timeto then '0.' || (cast(substr(timeto,1,2) as int) - cast(substr(timefrom,1,2) as int)) else 1.0 end as dailyduration,null as hours,accepted FROM vacancycalendar where uuid='" + uuid.uuid + "';"; - //dump("EVSQL: " + evsql + "\n"); - evdata = parent.appdb.dbquery(evsql); - evdata = evdata.sqldata[0]; - if (evdata.type == -1){ - $("#btnacceptvacancy").hide(); - }else { - $("#btnacceptvacancy").show(); - } - if (evdata.hours >= maxdayhours) { - evdata.hours=maxdayhours; - $('#dailyduration select').val("1.0"); - } else if (evdata.hours == maxhalfdayhours){ - $('#dailyduration select').val("0.4"); - } else { - $('#dailyduration select').val("0."); - } - - }else { - $('#dailyduration select').val("1.0"); - } - for (var w in evdata) { - if ((w == 'datefrom') || (w == 'dateto')) { - w='vac' + w; - } - - if ($("#frmeditvacancy #" + w)) { - //dump(w + "->"+evdata[w]+"\n"); - if (w == "type"){ - $("#frmeditvacancy #" + w + " select").val(evdata[w]); - } else { - $("#frmeditvacancy #" + w).val(evdata[w]); - } - - - } - - } - - setdailydurationfields(); - $("#edit_vacancy").modal('show'); -} - -function confirm_delete_vacancy(uuid) { - delvacation = uuid; - $("#confirm_delete_vacancy").modal('show'); - return false; -} - -function delete_vacancy() { - var delsql = "DELETE FROM vacancycalendar where uuid='" + delvacation+"';"; - parent.appdb.dbexec(delsql); - load_table_vacancy(); - delvacancy=null; - $("#confirm_delete_vacancy").modal('hide'); - - return false; -} - -function setdailydurationfields() { - var dd = $('#dailyduration :selected').val(); - if (dd=='1.0') { - //$("#ftimefrom").hide(); - $("#hours").prop("disabled",true); - }else if (dd=='0.4') { - //$("#ftimefrom").show(); - $("#hours").prop("disabled",true); - }else if (dd=='0.') { - //$("#ftimefrom").show(); - $("#hours").prop("disabled",false); - } -} - -function save_vacancy() { - var type = 'ins'; - var cuuid = ""; - if ($("#frmeditvacancy #uuid").val() != 0) { - type = 'upd'; - cuuid = $("#frmeditvacancy #uuid").val(); - } - var evsvdata = { - uuid:cuuid, - datefrom: $("#frmeditvacancy #vacdatefrom").val(), - dateto: $("#frmeditvacancy #vacdateto").val(), - timefrom: $("#frmeditvacancy #timefrom").val(), - hours: $("#frmeditvacancy #hours").val(), - description: $("#frmeditvacancy #description").val(), - staffuuid: $("#frmeditvacancy #staffuuid").val(), - type: $("#frmeditvacancy #type").val() - } - var savesql = ""; - if (type == 'ins') { - savesql = "INSERT INTO vacancycalendar (uuid, datefrom, dateto, timefrom, timeto, description, staffuuid, type,vacyear) VALUES " - +"('" + parent.appdb.generate_uuid() + "', date("+encodeparam(evsvdata.datefrom, 'date')+"), date("+encodeparam(evsvdata.dateto, 'date')+"), "+encodeparam(evsvdata.timefrom, 'text')+", strftime(\"%H:%M\",time("+encodeparam(evsvdata.timefrom, 'text')+",'+"+evsvdata.hours+" hours')), "+encodeparam(evsvdata.description, 'text')+", "+encodeparam(evsvdata.staffuuid, 'text')+","+evsvdata.type+","+encodeparam(evsvdata.datefrom, 'year')+");"; - } else { - savesql = "UPDATE vacancycalendar SET vacyear=" + encodeparam(evsvdata.datefrom, 'year') + ", datefrom = date("+encodeparam(evsvdata.datefrom, 'date')+"), dateto = date("+encodeparam(evsvdata.dateto, 'date')+"), timefrom = "+encodeparam(evsvdata.timefrom, 'text')+", timeto = strftime(\"%H:%M\",time("+encodeparam(evsvdata.timefrom, 'text')+",'+"+evsvdata.hours+" hours')), description = "+encodeparam(evsvdata.description, 'text')+", staffuuid = "+encodeparam(evsvdata.staffuuid, 'text')+", type = "+evsvdata.type+" WHERE uuid = '"+evsvdata.uuid+"';"; - } - //dump("VACSAVESQL:" + savesql + "\n"); - parent.appdb.dbexec(savesql); - load_table_vacancy(); - - $("#frmeditvacancy #uuid").val("0"); - $("#edit_vacancy").modal('hide'); -} - - -function set_selectyears() { - - var years = parent.appdb.dbquery("select strftime('%Y',coalesce(min(entrydate),date('now','-1 year'))) as minyear, strftime('%Y',date('now', '+1 year')) as maxyear from staff where uuid='"+pconfig.uuid+"';"); - var minyear = parseInt(years.sqldata[0].minyear); - var maxyear = parseInt(years.sqldata[0].maxyear); - for (var y=minyear;y<=maxyear;y++){ - - var sel = ""; - if (y == pconfig.year) { - sel=' selected="1" '; - - } - - $(".selyear").append(""); - } - -} - -function saveyearvacdays() { - var csel = "select * from staffvacancydays where staffuuid='"+pconfig.uuid+"' and vacancyyear='"+pconfig.year+"';"; - var days = 0; - var hours = 0; - if ($('#vacancyyeartotal').val() === ""){ - return; - } - if (pconfig.vacancyunit == "hours"){ - days = parseFloat($('#vacancyyeartotal').val().replace(',','.')) / 8; - hours = $('#vacancyyeartotal').val(); - }else { - days = parseFloat($('#vacancyyeartotal').val().replace(',','.')); - hours = parseFloat($('#vacancyyeartotal').val().replace(',','.')) * 8; - } - var cnum = parent.appdb.dbquery(csel); - var inssql = "INSERT INTO staffvacancydays (staffuuid,vacancyyear,days,hours) VALUES ('"+pconfig.uuid+"','"+pconfig.year+"',"+days+","+hours+");"; - if (cnum.sqldata.length > 0) { - inssql = "UPDATE staffvacancydays SET days="+days+",hours="+hours+" where staffuuid='"+pconfig.uuid+"' and vacancyyear='"+pconfig.year+"';"; - } - parent.appdb.dbexec(inssql); - //calcvacancy(); -} - - - -function dlg_event(uuid, type) { - - if (type== "ins") { - - $('#btndeleteevent').hide(); - - }else { - $('#btndeleteevent').show(); - } - $('#frmeditevent #freqinterval').hide(); - $('#frmeditevent #freqmonthly').hide(); - $('#frmeditevent #freqweekly').hide(); - $('#frmeditevent #freq_monthly_byday').show(); - $('#frmeditevent #freq_monthly_bymonthday').hide(); - $('#frmeditevent #freq').val(""); - $('#frmeditevent .active').removeClass('active'); - if ((type == 'upd') || (type == 'ins')) { - - var evdata = { - uuid: '0', - description: '', - activityuuid:'', - location: '', - color: '', - datefrom:new Date().toISOString().substring(0,10), - dateto:'', - staffuuid: pconfig.uuid, - timefrom: '00:00', - timeto: '00:00', - freq: '', - staffname: $("#staff_prename").val() + " " + $("#staff_surname").val() - }; - //jsdump(JSON.stringify(pconfig) + "\n"); - //jsdump(JSON.stringify(evdata) + "\n"); - if (type == 'upd') { - var evsql = "SELECT uuid, strftime(\"%d.%m.%Y\",datefrom) as datefrom, strftime(\"%d.%m.%Y\",dateto) as dateto, timefrom, timeto, description, location, color, freq, '"+ pconfig.uuid+"' as staffuuid FROM eventcalendar ev left join staffplanning st on (ev.uuid=st.eventcalendaruuid) where ev.uuid='" + uuid.uuid + "' group by ev.uuid;"; - evdata = parent.appdb.dbquery(evsql); - evdata = evdata.sqldata[0]; - evdata['staffname'] = $("#staff_prename").val() + " " + $("#staff_surname").val(); - if (evdata.freq != '') { - var tmpfreq = evdata.freq.split(';'); - for (var t in tmpfreq){ - if (tmpfreq[t] != '') { - var spl = tmpfreq[t].split("="); - evdata[spl[0].toLowerCase()] = spl[1].toLowerCase(); - } - } - } - } - for (var w in evdata) { - if ($("#frmeditevent #" + w)) { - // if (w == 'staffuuid') { - // if (evdata[w] == '') { - // $("#frmeditevent #" + w).multiselect('select',[]); - // } else { - // $("#frmeditevent #" + w).multiselect('select',evdata[w].split(',')); - // } - - // } - // else if (w == 'color') { - // $("#frmeditevent #color").val(evdata[w]); - // $('#frmeditevent #color').minicolors('value',{color: evdata[w]}); - // } - // else { - $("#frmeditevent #" + w).val(evdata[w]); - // } - } - } - if ((evdata.freq == 'weekly') && (evdata.byday)) { - var bd = evdata.byday.split(','); - for (var i in bd){ - document.getElementById('weekly_byday_' + bd[i]).setAttribute("checked",true); - $('#frmeditevent #weekly_byday_' + bd[i]).parent().addClass("active"); - } - } - if (evdata.freq == 'monthly') { - $('#freq_monthly_byday').hide(); - $('#freq_monthly_bymonthday').hide(); - $('#pnl_monthly_byday').removeAttr("checked"); - $('#pnl_monthly_bymonthday').removeAttr("checked"); - if (evdata.byday) { - document.getElementById('pnl_monthly_byday').setAttribute("checked",true); - $('#frmeditevent #pnl_monthly_byday').parent().addClass("active"); - $('#freq_monthly_byday').show(); - var bd = evdata.byday.split(','); - var adpos = new Array(); - var awday = new Array(); - for (var i in bd){ - var wday = bd[i].substr(bd[i].length-2); - var pos = bd[i].substring(0,bd[i].length-2); - awday.push(wday.toLowerCase()); - adpos.push(pos); - } - - for (var i in adpos){ - document.getElementById('monthly_bydaypos_' + adpos[i]).setAttribute("checked",true); - $('#frmeditevent #monthly_bydaypos_' + adpos[i]).parent().addClass("active"); - } - for (var i in awday){ - document.getElementById('monthly_bydaywday_' + awday[i]).setAttribute("checked",true); - $('#frmeditevent #monthly_bydaywday_' + awday[i]).parent().addClass("active"); - } - }else if (evdata.bymonthday) { - document.getElementById('pnl_monthly_bymonthday').setAttribute("checked",true); - $('#frmeditevent #pnl_monthly_bymonthday').parent().addClass("active"); - $('#freq_monthly_bymonthday').show(); - var bd = evdata.bymonthday.split(','); - for (var i in bd){ - document.getElementById('monthly_bymonthday_' + bd[i]).setAttribute("checked",true); - $('#frmeditevent #monthly_bymonthday_' + bd[i]).parent().addClass("active"); - } - } - } - setfreq(); - $("#edit_event").modal('show'); - } -} - - -function save_event() { - var sql1 = new Array(); - var sql2 = new Array(); - if ($('#timefrom').val() == $('#timeto').val() || $('#timefrom').val() == "00:00" || $('#timeto').val() == "00:00"){ - errormsg("Erreur","les heures doivent être différent et différent de la valeur 00:00!"); - return false; - } - if ($('#timefrom').val() > $('#timeto').val()){ - errormsg("Erreur","l'heure de début ne peux pas être supérieur à l'heure de fin!"); - return false; - } - if (!$('#staffuuid').val()){ - errormsg("Erreur","Vous devez selectionner au moin 1 membre du staff!"); - return false; - } - if ($('#dateto').val() != '' && (encodeparam($('#datefrom').val()) > encodeparam($('#dateto').val())) ) { - errormsg("Erreur","La Date début ne peut pas être supérieur à la date fin!"); - return false; - } - var type = 'ins'; - var cuuid = ""; - if ($("#frmeditevent #uuid").val() != 0) { - type = 'upd'; - cuuid = $("#frmeditevent #uuid").val(); - } else { - cuuid = parent.appdb.generate_uuid(); - } - var freqdata = {}; - var cfreq = $("#frmeditevent #freq").val(); - $("#frmeditevent :input").each(function() { - var input = $(this); - - if (input.attr("id") && (input.attr("id") != "staffuuid") && (input.attr("id") != "staffname")) { - if ((input.attr("type") == "checkbox") && (input.attr("id").indexOf(cfreq) >= 0)){ - var xd = input.attr("id").split("_"); - if (input.attr("checked")) { - if (!freqdata[xd[1]]) { - freqdata[xd[1]] = new Array(); - } - freqdata[xd[1]].push(input.val()); - } - } - else if ((input.attr("type") == "radio") && (input.attr("id").indexOf(cfreq) >= 0)) { - var xd = input.attr("id").split("_"); - if (input.attr("checked")) { - freqdata['freqtype'] = xd[2]; - } - } - else if ((input.attr("type") != "checkbox") && ((input.attr("type") != "radio"))){ - if ((input.attr("id") == 'interval') || (input.attr("id") == 'freq')) { - freqdata[input.attr("id")] = input.val(); - } else if ((type == 'ins') && (input.attr("id") != 'staffuuid')) { - - sql1.push('"' + input.attr("id") + '"'); - if (input.attr("id") == 'uuid') { - if (input.val() == "" || input.val() == "0") { - sql2.push("'" + cuuid + "'"); - } else { - sql2.push("'" + input.val() + "'"); - } - } else { - var ival = encodeparam(input.val(), input.attr('type')); - sql2.push(ival); - } - } else { - if ((input.attr("id") != 'uuid') && (input.attr("id") != 'staffuuid')){ - var ival = encodeparam(input.val(), input.attr('type')); - sql2.push('"' + input.attr("id") + '"=' + ival); - } - } - } - } - - }); - if (!freqdata.freqtype) { - freqdata['freqtype'] = curfreq.freqtype; - } - - var strfreq =""; - if (cfreq != "") { - strfreq='FREQ=' + cfreq.toUpperCase()+';INTERVAL=' + freqdata.interval +';'; - if ((cfreq == 'weekly') && (freqdata.byday)){ - strfreq += 'BYDAY=' + freqdata.byday.join(","); - } - if ((cfreq == 'monthly') && (freqdata.bydaypos) || ((freqdata.bydaywday)) || (freqdata.bymonthday)){ - strfreq += freqdata.freqtype.toUpperCase() + '='; - if (freqdata.freqtype == 'bymonthday') { - strfreq += freqdata.bymonthday.join(',') + ";" - }else { - var abyday = new Array(); - for (var p in freqdata.bydaypos){ - for (var w in freqdata.bydaywday){ - abyday.push(freqdata.bydaypos[p] + freqdata.bydaywday[w]); - } - } - strfreq += abyday.join(","); - } - } - if (strfreq.slice(-1) == ';') { - strfreq = strfreq.substring(0,strfreq.length-1); - } - } - var staffuuids = $('#staffuuid').val(); - var delsql = ""; - var xsql = []; - if (type != 'ins') { - xsql.push("DELETE FROM staffplanning where eventcalendaruuid = '"+cuuid+"';"); - } - var staffinssql = ""; - - if (staffuuids && (staffuuids.length != 0)) { - - staffinssql = "INSERT INTO staffplanning (eventcalendaruuid,staffuuid) VALUES "; - var tmps = []; - var curcoworkerok = false; - for (var s in staffuuids){ - if (staffuuids[s] == pconfig.uuid){ - curcoworkerok = true; - } - tmps.push("('"+cuuid+"','"+staffuuids[s]+"')"); - } - if (!curcoworkerok){ - tmps.push("('"+cuuid+"','"+pconfig.uuid+"')"); - } - staffinssql += tmps.join(',') + ";"; - xsql.push(staffinssql); - } - if (staffuuids.length == 0){ - staffinssql = "INSERT INTO staffplanning (eventcalendaruuid,staffuuid) VALUES ('"+cuuid+"','"+pconfig.uuid+"');"; - xsql.push(staffinssql); - } - - - - if (type == 'upd') { - sql2.push('freq=' + encodeparam(strfreq)); - xsql.push("UPDATE eventcalendar SET " + sql2.join(',') + " where \"uuid\"='" + cuuid + "';"); - } else { - sql1.push('freq'); - sql2.push(encodeparam(strfreq)); - xsql.push("INSERT INTO eventcalendar (" + sql1.join(',') + ") VALUES (" + sql2.join(',') + ");"); - } - dump(JSON.stringify(xsql)); - for (var i in xsql){ - parent.appdb.dbexec(xsql[i]); - } - - load_event_data(); - - $("#frmeditevent #uuid").val("0"); - $("#edit_event").modal('hide'); -} - -function confirm_delete_event() { - $("#confirm_delete_event").modal('show'); - return false; -} - -function delete_event() { - parent.appdb.dbexec("DELETE FROM eventcalendar where uuid='" + $('#frmeditevent #uuid').val()+"';"); - parent.appdb.dbexec("DELETE FROM staffplanning where eventcalendaruuid='" + $('#frmeditevent #uuid').val()+"';"); - load_event_data(); - $("#confirm_delete_event").modal('hide'); - - return false; -} - - - -function setfreq() { - - curfreq.freq = $('#freq option:selected').val(); - - $('#freqinterval').hide(); - $('#freqmonthly').hide(); - $('#freqweekly').hide(); - if (curfreq.freq != "") { - - $('#lblfreq').text(lblfreq[curfreq.freq]); - $('#freqinterval').show(); - if (curfreq.freq != 'daily') { - $('#freq' + curfreq.freq).show(); - } - } - -} - -// function load_staff_selection(objid,option){ -// var stdata = parent.appdb.dbquery("select uuid, coalesce(surname,'') || ' ' || coalesce(prename,'') as name,case when color is null then '#000' else color end as color from staff order by surname,prename"); - -// stdata = stdata.sqldata; -// for (var s in stdata){ -// $('#' + objid).append(''); -// } - -// var copt = {}; -// if (option) { -// copt = option; -// } -// copt['enableHTML'] = true; -// copt['nonSelectedText']="Sélectionner un(e) employé(e)..."; -// copt['numberDisplayed']=5; -// copt['allSelectedText']='Tous'; -// copt['nSelectedText']=' selections'; - -// $('#' + objid).multiselect(copt); - -// } - -function accept_vacancy(){ - var cuuid = ""; - if ($("#frmeditvacancy #uuid").val() != 0) { - type = 'upd'; - cuuid = $("#frmeditvacancy #uuid").val(); - } - var xsql = "UPDATE vacancycalendar SET accepted='1' where \"uuid\"='" + cuuid + "';"; - parent.appdb.dbexec(xsql); - load_table_vacancy(); - - $("#frmeditvacancy #uuid").val("0"); - $("#edit_vacancy").modal('hide'); -} - -function getlastyearsrest(){ - var weekhours = $('#staff_weekhours').val(); - if (weekhours === '') { - $("#vacancylastyearrest").val(0); - return; - } - var df = new Date(pconfig.year-1,0,1); - var dt = new Date(pconfig.year-1,11,31); - var vcalcrestsql = "select (select hours from staffvacancydays where staffuuid='"+pconfig.uuid+ "' and vacancyyear="+df.getFullYear()+")-SUM(dayhours) AS hours from (" + - "select vd.daydate,case when daydate <= date('now') then 1 else 0 end as taken,case when vc.timefrom=vc.timeto then cast ("+weekhours+"/5 as real) else (cast (substr(vc.timeto,1,2) as int) + (cast(substr(vc.timeto,4,5) as int)/60)) - (cast(substr(vc.timefrom,1,2) as int) + (cast(substr(vc.timeto,4,5) as int)/60)) end as dayhours,type,case when type != -1 then accepted else '1' end as accepted "+ - "from vacancycalendar vc left join ( "+ - "select daydate from ( "; - - var yd = []; - for (var dx=df;dx<=dt;dx.setDate(dx.getDate()+1)){ - yd.push("select date('"+dx.toISOString().substring(0,10)+"') as daydate"); - } - vcalcrestsql += yd.join(" UNION ") + - ") yd where strftime('%w',daydate) not in ('0','6') and daydate not in (select vacancydate from vacancy where vacancydate between '"+df.getFullYear()+"-01-01' and '"+dt.getFullYear()+"-12-31' and vacancydateto is null) " + - ") vd on (vd.daydate between vc.datefrom and vc.dateto) " + - "left join staffvacancydays svd on (vc.staffuuid=svd.staffuuid) " + - "where vc.staffuuid='"+pconfig.uuid+ "' and daydate is not null group by daydate) where type in (0,1) and taken=1 and accepted=1 group by taken,accepted;"; - //dump("SQLREST:" + vcalcrestsql + "\n"); - var vcalc = parent.appdb.dbquery(vcalcrestsql); - //dump(JSON.stringify(vcalc) + "\n"); - if (vcalc && vcalc.sqldata[0]){ - - $("#vacancylastyearrest").val(vcalc.sqldata[0].hours); - }else { - $("#vacancylastyearrest").val(0); - } - return; -} diff --git a/TODO/modules_todo/staff/js/staff.js b/TODO/modules_todo/staff/js/staff.js deleted file mode 100644 index 1b4b53a..0000000 --- a/TODO/modules_todo/staff/js/staff.js +++ /dev/null @@ -1,119 +0,0 @@ -//Source-code licensed under EUPL v1.2 ( Copyright 2019 By DKS s.à r.l. - Kilian Saffran - Luxembourg ) -var pconfig = {}; -var delcoworker = null; -var wh = window.innerHeight - 100; -var tblstaff = null; - -function initdata() { - - loadtable(); - set_infoheader(""); - pconfig = parent.apppref.getpreference("staff"); - if (!pconfig.printlayout) { - pconfig.printlayout = 'list'; - parent.apppref.setpreference("staff", pconfig); - } - - } - -function loadtable() { - var delbtn = ""; - if (parent.app.info.modules.stafflist.delete == true){ - delbtn = ""; - } - var sql = "SELECT '"+delbtn+"' as action, coalesce(prename,'') || '
' || coalesce(surname,'') as name,case when color is not null then '
' else null end color, coalesce(address,'')|| '
' || coalesce(zip,'') || ' ' || coalesce(city,'') || '
' || coalesce(country,'') as address, case when phone is not null then ': ' || phone || '
' else '' end || case when email is not null then ':' || email else '' end as phonemail, coalesce(jobtitle,'') || '
' || case when entrydate is not null then 'à partir du: ' || strftime('%d.%m.%Y',entrydate) else '' end || case when exitdate is not null then ' jusqu''au: ' || strftime('%d.%m.%Y',exitdate) else '' end as jobtitle FROM staff;"; - //dump("STAFFSQL:" +sql + "\n"); - var data = parent.appdb.dbqueryarray(sql); - - var headerdata = getlabels(data.sqlhead.join(",")); - $("#tbl_staff").html(""); - tblstaff = $("#tbl_staff").dataTable({ - "language": { - "url": "../../../oldvendor/js/locale/datatable_fr.json" - }, - "data": data.sqldata, - "columns": headerdata, - "paging": false, - "scrollY": wh + "px", - "scrollCollapse": true, - "ordering": true, - "info": false, - "filter": true, - "destroy": true - }); -// $('#tbl_staff').on('search.dt', function() { -// pconfig.filter = tblstaff.api().search(); -// parent.apppref.setpreference("pageconfig.staff", pconfig); -// }); - - $('#tbl_staff').on('order.dt', function() { - pconfig.order = tblstaff.fnSettings().aaSorting; - parent.apppref.setpreference("pageconfig.staff", pconfig); - - }); -// if (pconfig.filter) { -// tblstaff.fnFilter(pconfig.filter); -// } - if (pconfig.order) { - tblstaff.fnSort(pconfig.order); - } - if (/*(!pconfig.filter) && */ (!pconfig.order)) { - tblstaff.fnDraw(); - } -} - - - -function add_coworker() { - var newuuid = parent.appdb.generate_uuid(); - parent.appdb.dbexec("insert into staff (uuid) VALUES ('" + newuuid + "');"); - parent.app.loadpage('modules/staff/coworker.html',{uuid:newuuid}); - -} - -function confirm_delete_coworker(myuuid) { - - delcoworker = myuuid; - $("#confirm_delete_coworker").modal('show'); - return false; -} - -function delete_coworker() { - //var frmdata = new Object(); - //parent.appdb.dbexec("DELETE FROM planningstaff where staffuuid='"+delcoworker +"';"); - var evdel = parent.appdb.dbquery("select eventcalendaruuid,count(staffuuid) as cnt from staffplanning where staffuuid='" + delcoworker + "';"); - - parent.appdb.dbexec("DELETE FROM staffvacancydays where staffuuid='" + delcoworker + "';"); - parent.appdb.dbexec("DELETE FROM vacancycalendar where staffuuid='" + delcoworker + "';"); - parent.appdb.dbexec("DELETE FROM staffplanning where staffuuid='" + delcoworker + "';"); - parent.appdb.dbexec("DELETE FROM staff where uuid='" + delcoworker + "';"); - for (var e in evdel.sqldata) { - if (evdel.sqldata[e].cnt == 1) { - parent.appdb.dbexec("DELETE FROM eventcalendar where uuid='" + evdel.sqldata[e].eventcalendaruuid + "';"); - } - } - // - delcoworker = null; - loadtable(); - // - $("#confirm_delete_coworker").modal('hide'); - -} - -function load_coworker(couuid){ - //"coworker uuid:" + couuid + "\n"); - var cwdata = parent.apppref.getpreference("pageconfig.coworker"); - var cow = new Object(); - if (cwdata && cwdata !== ""){ - cow = JSON.parse(cwdata); - } - //dump("Current CoWorker cfg:" +JSON.stringify(cow) + "\n"); - cow.uuid = couuid; - //dump("New CoWorker cfg:" +JSON.stringify(cow) + "\n"); - parent.apppref.setpreference("pageconfig.coworker",cow); - globelreq.send_request({page:'coworker', - module:'staff', - data:null, - header:'Employé(e)'}); - -} \ No newline at end of file diff --git a/TODO/modules_todo/staff/stafflist.html b/TODO/modules_todo/staff/stafflist.html deleted file mode 100644 index 6d4c218..0000000 --- a/TODO/modules_todo/staff/stafflist.html +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - StaffList - - - - - - - - - - - - - - - -
- -
- -
-
- -
-
- -
- - - - - - - - - - - diff --git a/apps/api/lib/pgsql.pm b/apps/api/lib/pgsql.pm index 2a93f10..e36a77c 100644 --- a/apps/api/lib/pgsql.pm +++ b/apps/api/lib/pgsql.pm @@ -22,12 +22,12 @@ sub new { # $self->{$x} = $p->{$x}; #} $self->{dbtype} = 'PgPP'; #PgPP,SQLite - #$self->{dbhost} = 'sql629.your-server.de'; - $self->{dbhost} = 'localhost'; + $self->{dbhost} = 'sql629.your-server.de'; + #$self->{dbhost} = 'localhost'; $self->{dbname} = 'dks_lu'; $self->{dbuser} = 'dks_lu'; - $self->{dbpassword} = 'dks_lu'; - #$self->{dbpassword} = 'DcrWuLd4KU3u68xd'; + #$self->{dbpassword} = 'dks_lu'; + $self->{dbpassword} = 'DcrWuLd4KU3u68xd'; return $self; } diff --git a/apps/data/db/lechatpotte.sqlite b/apps/data/db/lechatpotte.sqlite index bdfc251..b0f92ef 100644 Binary files a/apps/data/db/lechatpotte.sqlite and b/apps/data/db/lechatpotte.sqlite differ diff --git a/apps/data/db/underatert.sqlite b/apps/data/db/underatert.sqlite index 38e1b44..b4d60e2 100644 Binary files a/apps/data/db/underatert.sqlite and b/apps/data/db/underatert.sqlite differ diff --git a/apps/index.cgi b/apps/index.cgi index d975011..5d376b5 100644 --- a/apps/index.cgi +++ b/apps/index.cgi @@ -1,9 +1,10 @@ #!/usr/bin/perl use strict; +use File::Basename qw/dirname basename/; use lib ('./lib'); use lib ('./api/lib'); -use File::Basename; + use Template; use CGI; use CGI::Cookie; @@ -26,7 +27,8 @@ my $cookie; my $sess = (); my $se = session->new(); my $page = "index.tt"; -my $basepath = substr(dirname($0),length($ENV{"DOCUMENT_ROOT"})); +my $basepath = substr(dirname($ENV{"SCRIPT_FILENAME"}),length($ENV{"DOCUMENT_ROOT"})); +# my $basepath = $ENV{"DOCUMENT_ROOT"}; my $filepath = substr($cgi->url({-absolute=>1}),length($basepath)+1); #if (exists($p->{p})){ if ($filepath ne ""){ @@ -79,21 +81,21 @@ if (($ENV{HTTP_USER_AGENT} !~ /Chrome/) || ($ENV{HTTP_USER_AGENT} =~ /Edge/) || # } print $cgi->header(-type=>'text/html', -charset=>"utf-8",-cookie => $cookie); -my $template = Template->new({INCLUDE_PATH => [dirname($0).'/tmpl']}); +my $template = Template->new({INCLUDE_PATH => [dirname($ENV{"SCRIPT_FILENAME"}).'/tmpl']}); my @lv = split(/\//,$filepath); my $absnum = scalar(@lv)-1; my $vars->{abspath} = ""; for (my $i=0;$i<$absnum;$i++){ $vars->{abspath} .= "../"; } - +$vars->{filepath} = $filepath; $vars->{basepath} = $basepath; $vars->{page} = $page; $vars->{pagename} = basename($page); $vars->{pagename} =~ s/\.tt$//; my ($appname) = $ENV{REQUEST_URI} =~ /.*\/apps\/(\w+)\/.*/; -# $vars->{requri} = $ENV{REQUEST_URI}; +#$vars->{requri} = $ENV{REQUEST_URI}; if ($p->{sid} ne ""){ $vars->{appname} = $appname; if (exists($sess->{$appname})){ @@ -113,9 +115,3 @@ $template->process($skl,$vars) || die "Template process failed: ", $template->er # for my $header ( keys %headers ) { # print "$header: $headers{$header}
"; # } -# for my $e ( keys %ENV ) { -# print "ENV: $e: ".$ENV{$e}."
"; -# } -# print '/*'.Dumper($vars).'*/'; -# print '/*'.Dumper($p).'*/'; - diff --git a/apps/js/app.js b/apps/js/app.js index b871a9a..c290a08 100644 --- a/apps/js/app.js +++ b/apps/js/app.js @@ -130,10 +130,11 @@ document.addEventListener("keydown", function(e) { } - + var https = 'https'; $(document).ready(function() { - app.baseurl = ('https' == document.location.protocol ? 'https' : 'http') + '://' + location.host + location.pathname.substring(0,location.pathname.lastIndexOf('/apps/')+6); - var tmpurl = ('https' == document.location.protocol ? 'https' : 'http') + '://' + location.host + location.pathname.substring(0,location.pathname.lastIndexOf('/')); + + app.baseurl = https + '://' + location.host + location.pathname.substring(0,location.pathname.lastIndexOf('/apps/')+6); + var tmpurl = https + '://' + location.host + location.pathname.substring(0,location.pathname.lastIndexOf('/')); app.appname = tmpurl.substring(app.baseurl.length); app.getinfo(); app.loadsites(); diff --git a/apps/js/apps.js b/apps/js/apps.js index ee59312..b884dda 100644 --- a/apps/js/apps.js +++ b/apps/js/apps.js @@ -1,5 +1,6 @@ +var https ='https'; function logout() { - myurl = ('https:' == document.location.protocol ? 'https' : 'http') + '://'+ location.host + location.path; + myurl = https + '://'+ location.host + '/apps/'; $.ajax({ async: false, url: myurl, diff --git a/apps/js/webdatabase.js b/apps/js/webdatabase.js index 2912353..7f130f3 100644 --- a/apps/js/webdatabase.js +++ b/apps/js/webdatabase.js @@ -2,7 +2,7 @@ var appdb = { dbquery: function(sQuery){ var type='querysorted'; var result= {sqldata:[]}; - + //console.log(sQuery); $.ajax({ encoding:"UTF-8", diff --git a/apps/lib.par b/apps/lib.par new file mode 100644 index 0000000..3013689 Binary files /dev/null and b/apps/lib.par differ diff --git a/apps/tmpl/creorga/index.tt b/apps/tmpl/creorga/index.tt index 8c4a16b..c582742 100644 --- a/apps/tmpl/creorga/index.tt +++ b/apps/tmpl/creorga/index.tt @@ -43,10 +43,8 @@ [% END %] - - - - [% IF creorga.modules.creche.menu %] + + [% IF creorga.modules.staff.menu %] [% END %] @@ -55,7 +53,9 @@
+ [% IF creorga.modules.creche.menu %] + [% END %] @@ -72,7 +72,7 @@ - + diff --git a/apps/tmpl/creorga/modules/staff/coworker.tt b/apps/tmpl/creorga/modules/staff/coworker.tt index e144482..6ec5195 100644 --- a/apps/tmpl/creorga/modules/staff/coworker.tt +++ b/apps/tmpl/creorga/modules/staff/coworker.tt @@ -112,13 +112,7 @@
- +
diff --git a/apps/tmpl/creorga/modules/staff/js/coworker.js b/apps/tmpl/creorga/modules/staff/js/coworker.js index 86df649..ce33f08 100644 --- a/apps/tmpl/creorga/modules/staff/js/coworker.js +++ b/apps/tmpl/creorga/modules/staff/js/coworker.js @@ -9,7 +9,7 @@ var curfreq ={}; var maxdayhours = null; var maxhalfdayhours = null; var tblvac = null; -//var lictype = parent.apppref.getpreference("support.lictype"); + function initdata() { load_helpers(); @@ -22,7 +22,7 @@ function initdata() { pconfig = {}; } parent.appdb.dbexec("update vacancycalendar set vacyear=strftime('%Y',datefrom) where vacyear is null;"); - //"get CoWorker cfg:" +JSON.stringify(pconfig) + "\n"); + if (!pconfig.year) { pconfig.year=new Date().getFullYear(); } @@ -30,7 +30,7 @@ function initdata() { pconfig.printlayout = 'list'; parent.apppref.setpreference("coworker",pconfig); } - var cdatasql = "SELECT jobtitle, prename, surname, address, zip, city, country, entrydate, exitdate, iban, bic, accountname, phone, email, uuid,color,weekhours,maxdayhours,case when password is not null and length(password) > 3 then 1 else 0 end as passwordset FROM staff where uuid='" + pconfig.uuid + "';"; + var cdatasql = "SELECT jobtitle, prename, surname, address, zip, city, country, entrydate, exitdate, iban, bic, accountname, phone, email, uuid,color,weekhours,maxdayhours FROM staff where uuid='" + pconfig.uuid + "';"; var cdata = parent.appdb.dbquery(cdatasql); cdata = cdata.sqldata[0]; for (var ci in cdata) { @@ -39,34 +39,15 @@ function initdata() { } } - - // var crdata = parent.appdb.dbquery("select stafflist from creche;"); - // if ((crdata) && (crdata.sqldata[0].stafflist == "1")){ - // $("#pwddata").hide(); - // } - // if (cdata) { - // set_infoheader(cdata.prename + " " + cdata.surname); - // } $('#staff_color').minicolors({theme:'bootstrap'}); set_selectyears(); - //load_staff_selection('staffuuid'); - if (pconfig && pconfig.activetab) { $('a[href="#'+pconfig.activetab+'"]').tab('show'); }else{ $('a[href="#vacancy"]').tab('show'); pconfig.activetab = 'vacancy'; } - -// if (pconfig && pconfig.vacancyunit){ -// //dump("has vacancy unit:" + pconfig.vacancyunit + "\n"); -// $('#vacancy_unit').val(pconfig.vacancyunit); -// }else { pconfig.vacancyunit = "hours"; -// $('#vacancy_unit').val("days"); -// } - - } @@ -550,7 +531,7 @@ function saveyearvacdays() { [% END %] [% IF creorga.modules.staff.planning %] function load_event_data() { - //dump("Load event Table!\n"); + var where = new Array(); where.push(" st.uuid in ('"+ pconfig.uuid + "')"); @@ -582,8 +563,7 @@ function load_event_data() { for (var c in caldata) { var tblrow = ""; tblrow += ''; - //tblrow += ""+caldata[c].description+"" + caldata[c].description + ""; - //tblrow += "" + caldata[c].staffnames + ""; + tblrow += "" + caldata[c].tbldatefrom + ""; tblrow += "" + caldata[c].timefrom + "- " + caldata[c].timeto + ""; @@ -604,13 +584,12 @@ function load_event_data() { tblrow += "" + rule2.toText() + ""; } catch (ex){ - //"ERROR! loading data!" + ex + " FREQ:" + freq2 + "\n"); + } tblrow += ""; tblbody.push(tblrow); } - - //load table + $("#tbl_activity").append(tblbody.join('')); $("#tbl_activity").append(""); @@ -657,8 +636,7 @@ function dlg_event(uuid, type) { freq: '', staffname: $("#staff_prename").val() + " " + $("#staff_surname").val() }; - //jsdump(JSON.stringify(pconfig) + "\n"); - //jsdump(JSON.stringify(evdata) + "\n"); + if (type == 'upd') { var evsql = "SELECT uuid, strftime(\"%d.%m.%Y\",datefrom) as datefrom, strftime(\"%d.%m.%Y\",dateto) as dateto, timefrom, timeto, description, location, color, freq, '"+ pconfig.uuid+"' as staffuuid FROM eventcalendar ev left join staffplanning st on (ev.uuid=st.eventcalendaruuid) where ev.uuid='" + uuid.uuid + "' group by ev.uuid;"; evdata = parent.appdb.dbquery(evsql); @@ -676,21 +654,9 @@ function dlg_event(uuid, type) { } for (var w in evdata) { if ($("#frmeditevent #" + w)) { - // if (w == 'staffuuid') { - // if (evdata[w] == '') { - // $("#frmeditevent #" + w).multiselect('select',[]); - // } else { - // $("#frmeditevent #" + w).multiselect('select',evdata[w].split(',')); - // } - - // } - // else if (w == 'color') { - // $("#frmeditevent #color").val(evdata[w]); - // $('#frmeditevent #color').minicolors('value',{color: evdata[w]}); - // } - // else { + $("#frmeditevent #" + w).val(evdata[w]); - // } + } } if ((evdata.freq == 'weekly') && (evdata.byday)) { @@ -931,26 +897,5 @@ function setfreq() { } -// function load_staff_selection(objid,option){ -// var stdata = parent.appdb.dbquery("select uuid, coalesce(surname,'') || ' ' || coalesce(prename,'') as name,case when color is null then '#000' else color end as color from staff order by surname,prename"); - -// stdata = stdata.sqldata; -// for (var s in stdata){ -// $('#' + objid).append(''); -// } - -// var copt = {}; -// if (option) { -// copt = option; -// } -// copt['enableHTML'] = true; -// copt['nonSelectedText']="Sélectionner un(e) employé(e)..."; -// copt['numberDisplayed']=5; -// copt['allSelectedText']='Tous'; -// copt['nSelectedText']=' selections'; - -// $('#' + objid).multiselect(copt); - -// } diff --git a/apps/tmpl/skeleton/index.tt b/apps/tmpl/skeleton/index.tt index 64d7749..44a89b7 100644 --- a/apps/tmpl/skeleton/index.tt +++ b/apps/tmpl/skeleton/index.tt @@ -4,24 +4,24 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - + + + + DKS - Apps @@ -58,8 +58,8 @@