From: kilian (dks-laptop) Date: Fri, 31 Jan 2020 18:43:18 +0000 (+0100) Subject: v20200131 X-Git-Tag: 1.0.15~70 X-Git-Url: http://cloud.dks.lu/git/?a=commitdiff_plain;h=d27e06696631fff19edd277b316f1aa339a6a752;p=pot_lu.git v20200131 --- diff --git a/backoffice/api/db.cgi b/backoffice/api/db.cgi index 50685ab6..315b858a 100755 --- a/backoffice/api/db.cgi +++ b/backoffice/api/db.cgi @@ -110,19 +110,21 @@ if (($cgi->request_method() eq "GET") || ($cgi->request_method() eq "POST")){ $type = "upd"; } #print Dumper($type); - print Dumper($x); + #print Dumper($x); my @sql = (); if ($type eq "ins"){ - @sql = $db->create_ddl_insert($x); }else { @sql = $db->create_ddl_update($x); + #print Dumper(@sql); } - $html->{result}->{sql} = \@sql; + + $html->{test}->{sql} = \@sql; #print Dumper(@sql); if (scalar(@sql) > 0 ){ #print Dumper($sql[0]); - my $rid = $db->dbquerysorted($sql[0]); + #my $rid = $db->dbquerysorted($sql[0]); + my $rid = {}; if (keys(%{$rid}) > 0 ){ $html->{result} = $rid->{0}; } @@ -130,6 +132,7 @@ if (($cgi->request_method() eq "GET") || ($cgi->request_method() eq "POST")){ } else { $html->{result} = "ERROR: no idents!"; } + print Dumper($html); } elsif (exists($p->{del})){ my $x = $p; @@ -154,7 +157,19 @@ if (($cgi->request_method() eq "GET") || ($cgi->request_method() eq "POST")){ $html->{result} = $rid->{0}; } } + elsif (exists($p->{action})){ + my $x = $p; + my $schema = "public"; + if (exists($p->{schemata})){ + $schema = $db->securetext($p->{schemata}); + } + my $rid = $db->dbexec("select * from ".$schema.".".$db->securetext($p->{action})."(".$db->securetext($p->{params}).");"); + if (keys(%{$rid}) > 0 ){ + $html->{result} = $rid->{0}; + } + } } + print JSON::PP::encode_json($html); # for my $e ( keys %ENV ) { # print "$e: $ENV{$e}
"; diff --git a/backoffice/api/index.cgi b/backoffice/api/index.cgi index 9edf8d5b..74b8b6e4 100755 --- a/backoffice/api/index.cgi +++ b/backoffice/api/index.cgi @@ -76,6 +76,7 @@ if (($cgi->request_method() eq "GET") || ($cgi->request_method() eq "POST")){ if ($p->{fn} eq "saveform"){ $html->{p} = $p; $html->{result}->{ident} = $p->{ident}; + #my $fn = $p->{fn}; delete $p->{ident}; delete $p->{fn}; delete $p->{sid}; @@ -105,6 +106,20 @@ if (($cgi->request_method() eq "GET") || ($cgi->request_method() eq "POST")){ } $html->{result} = $retid->{0}; + if (exists($p->{ident_reportperiod_id})){ + my $prdid = $p->{ident_reportperiod_id}; + if ($prdid eq ""){ $retid->{0};} + if ($prdid ne ""){ + $db->dbexec("select * from ".$p->{schemata}.".onchange_reportperiod(".$prdid.");"); + } + } + if (exists($p->{ident_reportperiod_id})){ + my $prdid = $p->{ident_reportperiod_id}; + if ($prdid eq ""){ $retid->{0};} + if ($prdid ne ""){ + $db->dbexec("select * from ".$p->{schemata}.".onchange_reportperiod(".$prdid.");"); + } + } #$p->{table},#$p->{field},$p->{value},$p->{id},$p->{type} } if($p->{fn} eq "deleterow"){ diff --git a/backoffice/api/lib/dksdb.pm b/backoffice/api/lib/dksdb.pm index 3a05754f..e80a7c65 100644 --- a/backoffice/api/lib/dksdb.pm +++ b/backoffice/api/lib/dksdb.pm @@ -155,7 +155,7 @@ sub dbqueryarray(){ my $sth = $dbh->prepare($stat); - $sth->execute() or print "dbqueryarray: ".$sth->errstr; + $sth->execute() or print "dbqueryarray: ".$stat."->".$sth->errstr; my $count = 0; while(my $data = $sth->fetchrow_hashref()) diff --git a/backoffice/img/icons/data_refresh.svg b/backoffice/img/icons/data_refresh.svg new file mode 100644 index 00000000..ee7af3ca --- /dev/null +++ b/backoffice/img/icons/data_refresh.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/backoffice/img/icons/data_refresh_white.svg b/backoffice/img/icons/data_refresh_white.svg new file mode 100644 index 00000000..e063d771 --- /dev/null +++ b/backoffice/img/icons/data_refresh_white.svg @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/backoffice/js/formsave.js b/backoffice/js/formsave.js index 06e5c0d3..ceb52f2c 100644 --- a/backoffice/js/formsave.js +++ b/backoffice/js/formsave.js @@ -254,7 +254,7 @@ function fillformbydataclass(dataclass,data,readonly = false){ function fillformbydataclass2(dataclass,choices,data){ //console.log(data); - //console.log("fill data class: " + dataclass); + console.log("fill data class: " + dataclass); var frm = document.querySelectorAll('.data_'+ dataclass); if (data){ diff --git a/backoffice/js/module_global.js b/backoffice/js/module_global.js index ec3d9b28..40d8d391 100644 --- a/backoffice/js/module_global.js +++ b/backoffice/js/module_global.js @@ -46,11 +46,11 @@ var timecalc = { if ((minutes == null) || (minutes == "")){ return "00:00";}; var hours = parseInt(minutes/60); var restminutes = minutes-(hours*60); - return hours+ ":"+ timecalc.lpad(restminutes,2,'0'); + return timecalc.lpad(hours,2,'0')+ ":"+ timecalc.lpad(restminutes,2,'0'); }, TimeToMinutes:function (strtime){ var hours = parseInt(strtime.substring(0,2)) * 60; - var minutes = parseInt(strtime.substr(3,5)); + var minutes = parseInt(strtime.substring(3,5)); return hours+minutes; }, lpad: function(str, length,padString) { @@ -76,6 +76,32 @@ var timecalc = { }, sundayAfter: function(sdate){ var nextSunday = new Date(); + }, + StringToTime: function(strin){ + strin = strin.substring(0,5); + strin = strin.replace(/\D/g,''); + console.log(strin); + if (strin.length == 0){ return "";} + if (strin.length <= 2){ + console.log(strin + "<=2"); + if (strin > "23") {return ""} else { + return timecalc.lpad(strin,2,'0')+":00"; + } + } else if (strin.length == 3){ + console.log(strin + "==3"); + var hours = strin.substring(0,1); + var minutes = strin.substring(1,3); + console.log(hours + ":" + minutes) + if (minutes > "59"){ return "";} + return timecalc.lpad(hours,2,'0')+ ":"+ timecalc.lpad(minutes,2,'0'); + } else if (strin.length == 4){ + console.log(strin + "==4"); + var hours = strin.substring(0,2); + var minutes = strin.substring(2,4); + if ((hours > "23") || (minutes > "59")){return "";} + return timecalc.lpad(hours,2,'0')+ ":"+ timecalc.lpad(minutes,2,'0'); + } + return ""; } } diff --git a/backoffice/tmp/staffworkplanform.html b/backoffice/tmp/staffworkplanform.html new file mode 100644 index 00000000..1ef0ce26 --- /dev/null +++ b/backoffice/tmp/staffworkplanform.html @@ -0,0 +1,88 @@ + + + + [% END %] + +
+ +
+ + + + + --> \ No newline at end of file diff --git a/backoffice/tmpl/block/dlgaction.tt b/backoffice/tmpl/block/dlgaction.tt new file mode 100644 index 00000000..3c5cee2e --- /dev/null +++ b/backoffice/tmpl/block/dlgaction.tt @@ -0,0 +1,71 @@ +[% PROCESS macro/fields.tt %] +
+ +
+
+ × +

+
+
+ + [% fieldhidden("dlgactionschema","action",'','') %] + [% fieldhidden("dlgactionfunction","action",'','') %] + [% fieldhidden("dlgparams","action",'','') %] +
+
+ + +
+
+
+ \ No newline at end of file diff --git a/backoffice/tmpl/macro/fields.tt b/backoffice/tmpl/macro/fields.tt index c65c1e45..519161af 100644 --- a/backoffice/tmpl/macro/fields.tt +++ b/backoffice/tmpl/macro/fields.tt @@ -115,14 +115,14 @@ [% END -%] -[% MACRO fieldtimebox(column,table,title,size,state,value) BLOCK -%] +[% MACRO fieldtimebox(column,table,title,size,state,value,class) BLOCK -%]
[% IF state == "disabled" || state == "readonly" %] - + [% ELSE %] - + x [% END %] diff --git a/backoffice/tmpl/module/companies/companies.js b/backoffice/tmpl/module/companies/companies.js index 59984491..9c3447e3 100644 --- a/backoffice/tmpl/module/companies/companies.js +++ b/backoffice/tmpl/module/companies/companies.js @@ -5,9 +5,21 @@ var companies ={ tbl: null, current_company: null, name: "companies", - choices:{}, + choices:{"reportperiodunit":null}, initform: function(){ - + flatpickr("#reportperiodstart",{altInput: true, + altFormat: "d.m.Y", + dateFormat: "Y-m-d", + "locale": "fr", + }); + companies.choices["reportperiodunit"] = new Choices('#reportperiodunit',{ + searchEnabled: false, + itemSelectText: '', + removeItemButton: false, + shouldSort: false, + shouldSortItems: false, + choices : [{"value":"week","label":"semaine(s)"},{"value":"month","label":"mois"}] + }); }, inittable: function(){ companies.initform(); @@ -51,7 +63,7 @@ var companies ={ }, gettbldata: function(){ //console.log("isadmin [% session.usergroups.search('admin') %]"); - [% IF session.usergroups.search('admin') != 1 %] + [% IF session.usergroup == 'admin' %] req.reqdata("POST", "db.cgi", { "get": companies.name + "list","schemata":schemata, "filter": "schemata in (select schemaaccess from public.vw_userschemaaccess where id=[% session.id %])"}, companies.loadtbldata); [% ELSE %] req.reqdata("POST", "db.cgi", { "get": companies.name + "list","schemata":schemata}, companies.loadtbldata); diff --git a/backoffice/tmpl/module/companies/index.tt b/backoffice/tmpl/module/companies/index.tt index 698f39a7..4afee1fa 100644 --- a/backoffice/tmpl/module/companies/index.tt +++ b/backoffice/tmpl/module/companies/index.tt @@ -1,4 +1,5 @@ [% PROCESS macro/fields.tt %] +
@@ -35,10 +36,20 @@ [% fieldeditbox('vatnumber','companies','No TVA Internationale','w3-third','','','LU12345678') %]
[% fieldeditbox('email','companies','E-Mail','w3-half','','','') %] + [% rdonly = 'readonly' %] + [% IF (session.usergroup == 'admin') %] + [% fieldeditbox('schemata','companies','Database-Schema','w3-half','readonly','','') %] + [% rdonly = '' %] + [% END %] +
+
Configuration Périodes
+ [% fielddatebox("reportperiodstart","companies","début",'w3-fifth','','',rdonly) %] + [% fieldnumberbox("reportperiodlength","companies","Durée",'w3-fifth','','',rdonly,1,'',1) %] + [% fieldselectbox("reportperiodunit","companies","Unité",'w3-fifth','','',rdonly) %] +
- [% IF (session.usergroups.search('admin') == 1) %] - [% fieldeditbox('schemata','companies','Database-Schema','w3-half','readonly','','') %] - [% END %] + +
diff --git a/backoffice/tmpl/module/companies/staffgroups.js b/backoffice/tmpl/module/companies/staffgroups.js index c3992c8b..56cc4eec 100644 --- a/backoffice/tmpl/module/companies/staffgroups.js +++ b/backoffice/tmpl/module/companies/staffgroups.js @@ -19,7 +19,15 @@ var staffgroups = { columns: [{ title: "Département", field: "groupname" - }] + },{ + title: "Groupe standard", + field: "isdefault",formatter:"tickCross", formatterParams:{ + allowEmpty:true, + allowTruthy:true, + tickElement:'', + crossElement:'×', +} +}] }); staffgroups.gettbldata(); }, diff --git a/backoffice/tmpl/module/periods/index.js b/backoffice/tmpl/module/periods/index.js index fa045243..98c428cc 100644 --- a/backoffice/tmpl/module/periods/index.js +++ b/backoffice/tmpl/module/periods/index.js @@ -5,6 +5,7 @@ function initpage(){ console.log("Current Schema:" + schemata); reportperiod.inittable(); staffworkplan.inittable(); + //staffworkplan_daily.inittable(); module.viewpanel("tbl_reportperiod"); //call("reportperiod","inittable"); diff --git a/backoffice/tmpl/module/periods/index.tt b/backoffice/tmpl/module/periods/index.tt index 0467554c..f9d6d8d9 100644 --- a/backoffice/tmpl/module/periods/index.tt +++ b/backoffice/tmpl/module/periods/index.tt @@ -17,6 +17,8 @@ src="[% abspath%]img/icons/poticon.svg" style="height: 24px;" /> +
+ -
@@ -41,6 +48,7 @@
+
[% fieldtimebox("${wday}_timestart2",'staffworkplan','début 2','w3-fifth','','') %] [% fieldtimebox("${wday}_timeend2",'staffworkplan','fin 2','w3-fifth','','') %] - [% fieldtimebox("${wday}_timetotal",'staffworkplan',"Total",'w3-fifth','readonly','') %] - [% fieldtimebox("${wday}_interruption",'satffaworkplan','coupure','','readonly','') %] + [% fieldtimebox("${wday}_timepause",'staffworkplan','pause','w3-fifth','','') %] +
+
+ [% fieldtimebox("${wday}_workhours",'staffworkplan',"Total",'w3-fifth','readonly','') %] + [% fieldtimebox("${wday}_interruptionhours",'staffworkplan','coupure','','readonly','') %]
+ +
Congé
- [% fieldselectbox("${wday}_id_vacancytype",'staffworkplan','Type','w3-half','','','dayvacancy') %] - [% fieldtimebox("${wday}_vacancyhours",'staffworkplan','Heures','w3-half','','') %] + [% fieldselectbox("${wday}_id_vacancytype",'staffworkplan','Type de congé','w3-half','','','dayvacancy') %] + [% fieldtimebox("${wday}_vacancyhours",'staffworkplan','Heures','w3-half','','','vacdaytotal') %] +
+ +
+
Repos
+ [% fieldselectbox("${wday}_id_recuperationtype",'staffworkplan','type de repos','w3-half','','','dayrepos') %] + [% fieldtimebox("${wday}_recuperationhours",'staffworkplan','Heures','w3-half','','','repdaytotal') %] +
+
-
-
Pointages
-
+
+
+
Total Jour
+ [% fieldtimebox("${wday}_dayhours",'staffworkplan','Total Jour','','readonly','','wdaytotal') %] +
+ +
+ [% END %] + +
+
- [% END %] - -
-
- - - - - + + + + + @@ -151,26 +191,26 @@
× -

editer/ajouter période

+

editer période

[% fieldhidden("id","reportperiod",'ident','') %] - [% fieldhidden("enddate","reportperiod",'','') %] -
- [% fieldeditbox("periodname","reportperiod","Nom",'','','','') %] -
+ [% #fieldhidden("enddate","reportperiod",'','') %] + + [% #fieldeditbox("periodname","reportperiod","Nom",'','','','') %] +
- [% fieldselectbox("id_staffgroup","reportperiod","Département",'w3-half','','','') %] + [% #fieldselectbox("id_staffgroup","reportperiod","Département",'w3-half','','','') %]
- [% fielddatebox("startdate","reportperiod","début",'w3-fifth','','','') %] - [% fieldnumberbox("periodlength","reportperiod","Durée",'w3-fifth','','','',1,'',1) %] - [% fieldselectbox("periodtype","reportperiod","Unité",'w3-fifth','','','') %] - [% fieldeditbox("dspenddate","display","fin",'w3-fifth','readonly','','') %] + [% #fielddatebox("startdate","reportperiod","début",'w3-fifth','','','') %] + [% #fieldnumberbox("periodlength","reportperiod","Durée",'w3-fifth','','','',1,'',1) %] + [% #fieldselectbox("periodtype","reportperiod","Unité",'w3-fifth','','','') %] + [% #fieldeditbox("dspenddate","display","fin",'w3-fifth','readonly','','') %]
- [% IF session.usergroup.search("manager") == 1 || session.usergroup.search("teamleader") == 1 || session.usergroup.search("admin") == 1 %] + [% IF session.usergroup == "manager" || session.usergroup == "admin" %]
[% fieldcheckbox("isvalidated","reportperiod","Validé",'','','1') %] [% fieldhidden("id_validateuser","reportperiod",'','') %] @@ -190,5 +230,7 @@ [% INCLUDE block/dlgmessage.tt %] [% INCLUDE block/dlgdataload.tt %] [% INCLUDE block/dlgreport.tt %] + [% INCLUDE block/dlgaction.tt %] - \ No newline at end of file + + \ No newline at end of file diff --git a/backoffice/tmpl/module/periods/reportperiod.js b/backoffice/tmpl/module/periods/reportperiod.js index c52e0aa1..fc0a7f29 100644 --- a/backoffice/tmpl/module/periods/reportperiod.js +++ b/backoffice/tmpl/module/periods/reportperiod.js @@ -27,24 +27,24 @@ var reportperiod ={ // // ], // "locale": "fr", // }); - reportperiod.choices["id_staffgroup"] = new Choices('#id_staffgroup',{ - searchEnabled: false, - itemSelectText: '', - removeItemButton: false, - choices : [] - }); - reportperiod.choices["periodtype"] = new Choices('#periodtype',{ - searchEnabled: false, - itemSelectText: '', - removeItemButton: false, - shouldSort: false, - shouldSortItems: false, - choices : [{"value":"week","label":"semaine(s)"},{"value":"month","label":"mois"}] - }); - reportperiod.getstaffgroups(); - document.getElementById("periodtype").addEventListener('change', function(event){reportperiod.setenddate(event);}); - document.getElementById("periodlength").addEventListener('change', function(event){reportperiod.setenddate(event);}); - document.getElementById("startdate").addEventListener('change', function(event){reportperiod.setenddate(event);}); + // reportperiod.choices["id_staffgroup"] = new Choices('#id_staffgroup',{ + // searchEnabled: false, + // itemSelectText: '', + // removeItemButton: false, + // choices : [] + // }); + // reportperiod.choices["periodtype"] = new Choices('#periodtype',{ + // searchEnabled: false, + // itemSelectText: '', + // removeItemButton: false, + // shouldSort: false, + // shouldSortItems: false, + // choices : [{"value":"week","label":"semaine(s)"},{"value":"month","label":"mois"}] + // }); + //reportperiod.getstaffgroups(); + //document.getElementById("periodtype").addEventListener('change', function(event){reportperiod.setenddate(event);}); + //document.getElementById("periodlength").addEventListener('change', function(event){reportperiod.setenddate(event);}); + //document.getElementById("startdate").addEventListener('change', function(event){reportperiod.setenddate(event);}); }, inittable: function(){ reportperiod.tbl = new Tabulator("#tbl_" + reportperiod.name, { @@ -53,12 +53,13 @@ var reportperiod ={ layout: "fitDataFill", selectable: 1, rowContext:function(e, row){e.preventDefault();}, - columns: [{title: "Nom", field: "periodname",headerFilter: "input"}, + columns: [ + //{title: "Nom", field: "periodname",headerFilter: "input"}, {title: "Déparement", field: "groupname",headerFilter: "input"}, { title: "Début",field: "startdate",formatter:"datetime",formatterParams:{inputFormat:"YYYY-MM-DD",outputFormat:"DD.MM.YYYY",invalidPlaceholder:""} }, { title: "Fin",field: "enddate",formatter:"datetime",formatterParams:{inputFormat:"YYYY-MM-DD",outputFormat:"DD.MM.YYYY",invalidPlaceholder:""} }, - { title: "Durée",field: "periodlength",formatter:"number" }, - { title: "Unité",field: "periodtype",formatter:"plaintext" }, + //{ title: "Durée",field: "periodlength",formatter:"number" }, + //{ title: "Unité",field: "periodtype",formatter:"plaintext" }, { title: "Validé",field: "isvalidated",formatter:"tickCross",align:"center",formatterParams:{allowEmpty:true,allowTruthy:false,tickElement:'',crossElement:''}}, { title: "Verfifié par",field: "userdisplayname",formatter:"plaintext" }, ] @@ -75,8 +76,9 @@ var reportperiod ={ }, add: function(){ //console.log("TEST Add Period!"); - cleanform(reportperiod.name); - module.viewdialog(reportperiod.name,null); + showactiondlg(schemata,"add_reportperiod","Ajouter","Ajouter prochaine periode?",null,''); + //cleanform(reportperiod.name); + //module.viewdialog(reportperiod.name,null); return false; }, edit: function(){ @@ -124,27 +126,27 @@ var reportperiod ={ document.getElementById('dlg_reportperiod').style.display='none'; return false; }, - setenddate(event){ - console.log("set EndDate"); - var startdate = document.getElementById("startdate").value; - var len = document.getElementById("periodlength").value; - var type = document.getElementById("periodtype").value; - console.log(startdate + " + " + len + " " + type ); - if (len > 0 && type && startdate){ - var xstartdate = moment(startdate); - var nenddate = null; - if (type == 'month'){ - nenddate = xstartdate.add(len,'months').subtract(1,'day'); - } else { - nenddate = xstartdate.add(len,'weeks').subtract(1,'day'); - } - document.getElementById("enddate").value=moment(nenddate).format('YYYY-MM-DD'); - document.getElementById("dspenddate").value=moment(nenddate).format('DD.MM.YYYY'); - } else { - document.getElementById("enddate").value=''; - document.getElementById("dspenddate").value=''; - } - }, + // setenddate(event){ + // console.log("set EndDate"); + // var startdate = document.getElementById("startdate").value; + // var len = document.getElementById("periodlength").value; + // var type = document.getElementById("periodtype").value; + // console.log(startdate + " + " + len + " " + type ); + // if (len > 0 && type && startdate){ + // var xstartdate = moment(startdate); + // var nenddate = null; + // if (type == 'month'){ + // nenddate = xstartdate.add(len,'months').subtract(1,'day'); + // } else { + // nenddate = xstartdate.add(len,'weeks').subtract(1,'day'); + // } + // document.getElementById("enddate").value=moment(nenddate).format('YYYY-MM-DD'); + // document.getElementById("dspenddate").value=moment(nenddate).format('DD.MM.YYYY'); + // } else { + // document.getElementById("enddate").value=''; + // document.getElementById("dspenddate").value=''; + // } + // }, save: function(){ // var dateend = document.getElementById("enddate").value; // if (dateend == ''){ @@ -157,7 +159,8 @@ var reportperiod ={ var bshowmsg = false; for (var f in flds){ console.log(f + ":" + flds[f]); - if (flds[f] == "" && f != "ident_reportperiod_id"){ + if (flds[f] == "" && f != "ident_reportperiod_id" && f != "reportperiod_isvalidated" && f != "reportperiod_id_validateuser"){ + console.log("break:" + f ); bshowmsg = true; } } @@ -178,18 +181,27 @@ var reportperiod ={ // module.viewpanel('tbl_staffworkplan'); // } // }, - getstaffgroups: function(){ - req.reqdata("POST","db.cgi",{"get":"staffgroupslist","schemata":schemata},reportperiod.fillstaffgroups); - }, - fillstaffgroups: function(data){ - fillselectlist(reportperiod.choices["id_staffgroup"],data.sqldata,'id','groupname'); + // getstaffgroups: function(){ + // req.reqdata("POST","db.cgi",{"get":"staffgroupslist","schemata":schemata},reportperiod.fillstaffgroups); + // }, + // fillstaffgroups: function(data){ + // fillselectlist(reportperiod.choices["id_staffgroup"],data.sqldata,'id','groupname'); - }, + // }, generatereport(){ var udata = reportperiod.tbl.getSelectedData(); if (udata[0]) { dlgreport.show('pot',udata[0],udata[0].periodname); } + }, + datarefresh(){ + showdataloaddlg('','
Attendez s.v.p.!
'); + req.reqdata("POST","db.cgi",{"action":"refreshperiods","schemata":schemata,"params":""},reportperiod.datarefreshdone); + return false; + }, + datarefreshdone(){ + closedataloaddlg(); + return false; } } \ No newline at end of file diff --git a/backoffice/tmpl/module/periods/staffworkplan.js b/backoffice/tmpl/module/periods/staffworkplan.js index aaae6ca5..1ea7fce5 100644 --- a/backoffice/tmpl/module/periods/staffworkplan.js +++ b/backoffice/tmpl/module/periods/staffworkplan.js @@ -1,14 +1,20 @@ //var tbl_staffworkplan = null; var weekdays= ["mon","tue","wed","thu","fri","sat","sun"]; var jscalcdays= ["sun","mon","tue","wed","thu","fri","sat"]; +var daycheck ={ + maxdayhours: 600, //minutes + maxinterruption: 180, //minutes + maxweekcheck: 2880//minutes +} var staffworkplan ={ tbl: null, current_workplan: null, datefrom: null, dateto: null, id_staffgroup: null, + //id_staff: null, name: "staffworkplan", - choices:{"id_staff_add":null,"id_workplan":null,"id_workplan_add":null,"mon_id_vacancytype":null,"tue_id_vacancytype":null},"wed_id_vacancytype":null,"thu_id_vacancytype":null,"fri_id_vacancytype":null,"sat_id_vacancytype":null,"sun_id_vacancytype":null, + choices:{"id_staff_add":null,"id_workplan":null,"id_workplan_add":null,"mon_id_vacancytype":null,"tue_id_vacancytype":null,"wed_id_vacancytype":null,"thu_id_vacancytype":null,"fri_id_vacancytype":null,"sat_id_vacancytype":null,"sun_id_vacancytype":null,"mon_id_recuperationtype":null,"tue_id_recuperationtype":null,"wed_id_recuperationtype":null,"thu_id_recuperationtype":null,"fri_id_recuperationtype":null,"sat_id_recuperationtype":null,"sun_id_recuperationtype":null}, dateinputs:{"dates_add":null,"daterange_add":null}, initform: function(){ flatpickr(".timefield",{ @@ -69,6 +75,16 @@ var staffworkplan ={ choices : [] }); } + for (var w in weekdays){ + staffworkplan.choices[weekdays[w] + "_id_recuperationtype"] = new Choices('#'+ weekdays[w] + "_id_recuperationtype",{ + searchEnabled: false, + itemSelectText: '', + removeItemButton: true, + shouldSort: false, + shouldSortItems: false, + choices : [] + }); + } // staffworkplan.choices["weekdays"] = new Choices('#weekdays',{ // searchEnabled: false, @@ -79,12 +95,24 @@ var staffworkplan ={ // choices : [{"value":"1","label":"Lundi"},{"value":"2","label":"Mardi"},{"value":"3","label":"Mecredi"},{"value":"4","label":"Jeudi"},{"value":"5","label":"Vendredi"},{"value":"6","label":"Samedi"},{"value":"7","label":"Dimanche"}] // }); staffworkplan.getvacancy(); + staffworkplan.getrecuperation(); staffworkplan.getwptemplates(); staffworkplan.choices["id_workplan"].passedElement.element.addEventListener('change', function(event){staffworkplan.getworkplan(event,this.id)},false); staffworkplan.choices["id_workplan_add"].passedElement.element.addEventListener('change', function(event){staffworkplan.getworkplan_add(event,this.id)},false); var tfields = document.getElementsByClassName("timefield"); for (var i=0;i event checkdaytime" ); + tfields[i].addEventListener("change",function(){staffworkplan.checkdaytime(this.id);}); + } else if (!tfields[i].readonly){ + console.log("timefield:" + tfields[i].id + "=> event checkworktime" ); + tfields[i].addEventListener("change",function(){staffworkplan.checkworktime(this.id);}); + } else { + console.log("timefield:" + tfields[i].id + "=> no event" ); + } + } var vfields = document.getElementsByClassName("dayvacancy"); for (var i=0;ià réc.", field:"week_contractdiff" }, - { title: "Total
Semaine", field:"week_timetotal", bottomCalc:staffworkplan.periodtimesum}, - { title: "Lundi", - columns: [ - { title: "heures",field: "dspmontimes",formatter: "html",width:120 }, - { title: "total",field: "mon_timetotal",formatter: "html" }, - { title: "congé",field: "dspmonvacancy", formatter: "html"}, - ] - }, - { title: "Mardi", - columns: [ - { title: "heures",field: "dsptuetimes",formatter: "html",width:120 }, - { title: "total",field: "tue_timetotal",formatter: "html" }, - { title: "congé",field: "dsptuevacancy", formatter: "html" }, - ] }, - { title: "Mercredi", - columns: [ - { title: "heures",field: "dspwedtimes",formatter: "html",width:120 }, - { title: "total",field: "wed_timetotal",formatter: "html" }, - { title: "congé",field: "dspwedvacancy", formatter: "html" }, - ] }, - { title: "Jeudi",columns: [ - { title: "heures",field: "dspthutimes",formatter: "html",width:120 }, - { title: "total",field: "thu_timetotal",formatter: "html" }, - { title: "congé",field: "dspthuvacancy", formatter: "html" }, - ] }, - { title: "Vendredi",columns: [ - { title: "heures",field: "dspfritimes",formatter: "html",width:120 }, - { title: "total",field: "fri_timetotal",formatter: "html" }, - { title: "congé",field: "dspfrivacancy", formatter: "html" }, - ] }, - { title: "Samedi",columns: [ - { title: "heures",field: "dspsatimes",formatter: "html",width:120 }, - { title: "total",field: "sat_timetotal",formatter: "html" }, - { title: "congé",field: "dspsatvacancy", formatter: "html" }, - ] }, - { title: "Dimanche",columns: [ - { title: "heures",field: "dspsuntimes",formatter: "html",width:120 }, - { title: "total",field: "sun_timetotal",formatter: "html" }, - { title: "congé",field: "dspsunvacancy", formatter: "html" }, - ] } + //{ title: "Semaine", field:"dspcalweek",formatter: "html",width:120}, + //{ title: "Total
à réc.", field:"hoursdiff" }, + { title: "Lundi", field: "dspmontimes",formatter: "html"}, + { title: "Mardi",field: "dsptuetimes",formatter: "html" }, + { title: "Mercredi",field: "dspwedtimes",formatter: "html" }, + { title: "Jeudi",field: "dspthutimes",formatter: "html" }, + { title: "Vendredi",field: "dspfritimes",formatter: "html" }, + { title: "Samedi",field: "dspsattimes",formatter: "html" }, + { title: "Dimanche",field: "dspsuntimes",formatter: "html" } , + { title: "Totaux
Semaine", field:"dspweektotals",formatter: "html", bottomCalc:staffworkplan.periodtimesum,bottomCalcFormatter:"html"}, ] }); staffworkplan.gettbldata(); @@ -186,7 +202,7 @@ var staffworkplan ={ staffworkplan.dateinputs["daterange_add"].set('maxDate',staffworkplan.dateto); } if (staffworkplan.datefrom && staffworkplan.dateto){ - req.reqdata("POST", "db.cgi", { "get": staffworkplan.name + "list","schemata":schemata,"filter": "weekstart>=date('"+staffworkplan.datefrom+"') and weekend<=date('"+staffworkplan.dateto+"')" }, staffworkplan.loadtbldata); + req.reqdata("POST", "db.cgi", { "get": staffworkplan.name + "list","schemata":schemata,"filter": "id_staffgroup="+staffworkplan.id_staffgroup+" and weekstart>=date('"+staffworkplan.datefrom+"') and weekend<=date('"+staffworkplan.dateto+"')" }, staffworkplan.loadtbldata); } return false; }, @@ -201,6 +217,8 @@ var staffworkplan ={ }, edit: function(){ + //staffworkplan_daily.gettbldata(); + // module.viewpanel('tbl_daystaffworkplan'); var udata = staffworkplan.tbl.getSelectedData(); @@ -209,22 +227,37 @@ var staffworkplan ={ console.log(udata[0]); var wpdata = ""; cleanform2(staffworkplan.name + "_edit",staffworkplan.choices); - req.reqdata("POST", "db.cgi", { "get": staffworkplan.name + "_weekly","schemata":schemata, "filter":"id_staff=" + udata[0].id_staff + " and calweek='" + udata[0].calweek + "' AND calyear='"+ udata[0].calyear +"' "}, staffworkplan.fillform); + req.reqdata("POST", "db.cgi", { "get": staffworkplan.name + "data","schemata":schemata, "filter":"id_staff=" + udata[0].id_staff + " and daydate between date('" + udata[0].weekstart + "') AND date('"+ udata[0].weekend +"') "}, staffworkplan.fillform); module.viewpanel('frm_' +staffworkplan.name + "_edit"); } }, fillform: function(data){ if (data && data.sqldata){ - var datesdata = data.sqldata[0]["dates"].split(","); - for (var d in datesdata){ - document.getElementById(moment(datesdata[d]).format('ddd').toLowerCase() + "_title").innerHTML = moment(datesdata[d]).lang("fr").format('dddd, DD.MM.YYYY'); - document.getElementById(moment(datesdata[d]).format('ddd').toLowerCase()+ "_daydate").value=moment(datesdata[d]).format('YYYY-MM-DD'); - //console.log(moment(datesdata[d]).lang("fr").format('dddd, le DD.MM.YYYY') + "->" +moment(datesdata[d]).format('ddd').toLowerCase() ); + var newformdata = {}; + newformdata["id_staff"] = data.sqldata[0]["id_staff"]; + newformdata["dspstaffname"] = data.sqldata[0]["staffname"]; + for (var i in data.sqldata){ + var drow = data.sqldata[i]; + document.getElementById(drow["weekday"] + "_title").innerHTML = moment(drow["daydate"] ).lang("fr").format('dddd, DD.MM.YYYY'); + for (var k in drow){ + if ((k != 'id_staff') && (k != 'staffname') && (k != 'weekday') + && (k != 'id_staffgroup') && (k != 'calweek') && (k != 'calyear') && (k != 'id_reportperiod')){ + newformdata[drow["weekday"] + "_"+ k] = drow[k]; + //console.log( drow["weekday"] + "_"+ k + " => " + drow[k]); + } + + } } - // data.sqldata[0]["dates"] = - //data.sqldata[0]["id_staff"] = '["' + data.sqldata[0]["id_staff"].split('","') + '"]'; - fillformbydataclass2(staffworkplan.name,staffworkplan.choices,data.sqldata[0]); + //var datesdata = data.sqldata[0]["dates"].split(","); + // for (var d in datesdata){ + // document.getElementById(moment(datesdata[d]).format('ddd').toLowerCase() + "_title").innerHTML = moment(datesdata[d]).lang("fr").format('dddd, DD.MM.YYYY'); + // document.getElementById(moment(datesdata[d]).format('ddd').toLowerCase()+ "_daydate").value=moment(datesdata[d]).format('YYYY-MM-DD'); + // //console.log(moment(datesdata[d]).lang("fr").format('dddd, le DD.MM.YYYY') + "->" +moment(datesdata[d]).format('ddd').toLowerCase() ); + // } + // // data.sqldata[0]["dates"] = + // //data.sqldata[0]["id_staff"] = '["' + data.sqldata[0]["id_staff"].split('","') + '"]'; + fillformbydataclass2(staffworkplan.name,staffworkplan.choices,newformdata); } }, remove: function(){ @@ -237,29 +270,7 @@ var staffworkplan ={ save_edit: function(){ var datamsg = ""; var wpdata = getformcontent(staffworkplan.name + "_edit"); - //console.log(wpdata); - - // if (!wpdata["staffworkplan_id_staff"]){ - // datamsg += "pas d'employé(es) défini(es)!
"; - // } - // if (wpdata["staffworkplan_dates"] == "" && wpdata["staffworkplan_daterange"] == ""){ - // datamsg += "pas de date(s) définie(s)!
"; - // } - // var ttlcnt = 0; - // for (var f in wpdata){ - // if (f.endsWith("timetotal")){ - // if (wpdata[f] != ""){ - // ttlcnt++; - // } - // } - // } - // if (ttlcnt == 0){ - // datamsg += "pas de heures définie(s)!
" - // } - // if (datamsg != ""){ - // showmessagedlg("Configuration incomplète!",'
'+ datamsg+'
'); - // return false; - // } + var allrows=[]; showdataloaddlg('','
Attendez s.v.p.!
'); for (var w in weekdays){ @@ -276,12 +287,12 @@ var staffworkplan ={ } } - console.log("End save!"); + //console.log("End save!"); //console.log(allrows) for (var r in allrows){ allrows[r]["upsert"] = "1"; allrows[r]["schemata"] = schemata; - //console.log(allrows[r]); + console.log(allrows[r]); req.reqdata("POST","db.cgi",allrows[r],staffworkplan.workplansaved); } setTimeout("staffworkplan.workplanlastsaved()","1000"); @@ -301,7 +312,7 @@ var staffworkplan ={ } if (wpdata){ - console.log(wpdata); + //console.log(wpdata); } if (!wpdata["staffworkplan_id_staff"]){ datamsg += "pas d'employé(es) défini(es)!
"; @@ -311,7 +322,7 @@ var staffworkplan ={ } var ttlcnt = 0; for (var f in wpdata){ - if (f.endsWith("timetotal")){ + if (f.endsWith("workhours")){ if (wpdata[f] != ""){ ttlcnt++; } @@ -373,7 +384,7 @@ var staffworkplan ={ } } - console.log("End Prepare Data!"); + //console.log("End Prepare Data!"); //console.log(allrows) for (var r in allrows){ allrows[r]["upsert"] = "1"; @@ -387,13 +398,22 @@ var staffworkplan ={ }, getvacancy: function(){ - req.reqdata("POST","db.cgi",{"get":"vacancylist","schemata":schemata}, staffworkplan.fillvacancy); + req.reqdata("POST","db.cgi",{"get":"vacancylist","schemata":schemata,"filter":"isworktime=true"}, staffworkplan.fillvacancy); }, fillvacancy: function(data){ for (var w in weekdays){ fillselectlist(staffworkplan.choices[weekdays[w] + "_id_vacancytype"],data.sqldata,'id','vacancyname'); } }, + getrecuperation: function(){ + + req.reqdata("POST","db.cgi",{"get":"vacancylist","schemata":schemata,"filter":"isworktime=false"}, staffworkplan.fillrecuperation); + }, + fillrecuperation: function(data){ + for (var w in weekdays){ + fillselectlist(staffworkplan.choices[weekdays[w] + "_id_recuperationtype"],data.sqldata,'id','vacancyname'); + } + }, getstaff: function(){ //console.log("Get Staff for Plan!"); req.reqdata("POST","db.cgi",{"get":"staffworkplanstafflist","fields":"id_staff,staffname","schemata":schemata,"filter":"id_staffgroup="+ staffworkplan.id_staffgroup +" and startdate <= date('"+staffworkplan.dateto+"') and (enddate >= date('"+staffworkplan.datefrom+"') or enddate is null) group by id_staff,staffname"},staffworkplan.fillstaff); @@ -418,22 +438,23 @@ var staffworkplan ={ //console.log(data.sqldata[0]); var wpdata = data.sqldata[0]; delete wpdata["id"]; - fillformbydataclass2("staffworkplan",data.sqldata[0],false); + //console.log(wpdata); + fillformbydataclass2("staffworkplan",{},wpdata); for (var w in weekdays){ //console.log() - staffworkplan.checktime(weekdays[w] + "_timestart1"); + staffworkplan.checkworktime(weekdays[w] + "_timestart1"); } } }, getworkplan_add: function(ev,id){ - console.log("Get ADD Workplan DATA"); - console.log(id + "=>" + ev.detail.value); + //console.log("Get ADD Workplan DATA"); + //console.log(id + "=>" + ev.detail.value); req.reqdata("POST","db.cgi",{"get":"workplansdata","schemata":schemata,"filter":"id=" + ev.detail.value},staffworkplan.setworkplan_add); }, setworkplan_add: function(data){ - console.log("set Workplan add"); - console.log(data.sqldata[0]); + //console.log("set Workplan add"); + //console.log(data.sqldata[0]); if (data && data.sqldata){ //console.log(data.sqldata[0]); var wpdata = data.sqldata[0]; @@ -443,8 +464,8 @@ var staffworkplan ={ wpdata_add[w+ "_add"] = wpdata[w]; } delete wpdata["id"]; - console.log("Data to add" ); - console.log(wpdata_add); + //console.log("Data to add" ); + //console.log(wpdata_add); fillformbydataclass2("staffworkplan_add",staffworkplan.choices,wpdata_add); for (var w in weekdays){ //console.log() @@ -457,11 +478,20 @@ var staffworkplan ={ wday = id.substring(0,3); if (ev.detail.value == ""){ document.getElementById(wday + "_vacancyhours")._flatpickr.clear(); - } else if (document.getElementById(wday + "_vacancyhours").value == ""){ + } else if (document.getElementById(wday + "_vacancyhours").value){ document.getElementById(wday + "_vacancyhours")._flatpickr.setDate(document.getElementById(wday + "_timetotal").value); } }, - checktime: function(id){ + setrecuperationhours: function(ev,id){ + //console.log("Vacancy: " + id); + wday = id.substring(0,3); + if (ev.detail.value == ""){ + document.getElementById(wday + "_recuperationhours")._flatpickr.clear(); + } else if (document.getElementById(wday + "_recuperationhours").value){ + document.getElementById(wday + "_recuperationhours")._flatpickr.setDate(document.getElementById(wday + "_timetotal").value); + } + }, + checkworktime: function(id){ var pp = id.split("_"); @@ -470,44 +500,125 @@ var staffworkplan ={ if (pp.length > 2){ strappend = "_" + pp[2]; } - console.log("timefield: " + wday +"=>" + id + " changed " + strappend); + //console.log("timefield: " + wday +"=>" + id + " changed " + strappend); var mt1 = 0; var mt2 = 0; var mtp = 0; var irupt = 0; - if ((document.getElementById(wday + "_timeend1" + strappend).value != "") && (document.getElementById(wday + "_timestart1" + strappend).value != "")){ - mt1 = timecalc.TimeToMinutes(document.getElementById(wday + "_timeend1" + strappend).value)-timecalc.TimeToMinutes(document.getElementById(wday + "_timestart1" + strappend).value); + var ode1 = document.getElementById(wday + "_timeend1" + strappend); + var ods1 = document.getElementById(wday + "_timestart1" + strappend); + var ode2 = document.getElementById(wday + "_timeend2" + strappend); + var ods2 = document.getElementById(wday + "_timestart2" + strappend); + var odp = document.getElementById(wday + "_timepause" + strappend); + var oirupt = document.getElementById(wday + "_interruptionhours" + strappend); + var owkh = document.getElementById(wday + "_workhours" + strappend); + //POT Time CALC + if (ode1.value && ods1.value){ + mt1 = timecalc.TimeToMinutes(ode1.value)-timecalc.TimeToMinutes(ods1.value); } - if ((document.getElementById(wday + "_timeend2" + strappend).value != "") && (document.getElementById(wday + "_timestart2" + strappend).value != "")){ - mt2 = timecalc.TimeToMinutes(document.getElementById(wday + "_timeend2" + strappend).value)-timecalc.TimeToMinutes(document.getElementById(wday + "_timestart2" + strappend).value); + if (ode2.value && ods2.value){ + mt2 = timecalc.TimeToMinutes(ode2.value)-timecalc.TimeToMinutes(ods2.value); } - if (document.getElementById(wday + "_timepause" + strappend).value != ""){ - mtp = timecalc.TimeToMinutes(document.getElementById(wday + "_timepause" + strappend).value); + if (odp.value){ + mtp = timecalc.TimeToMinutes(odp.value); } - if ((document.getElementById(wday + "_timeend1" + strappend).value != "") && (document.getElementById(wday + "_timestart2" + strappend).value != "")){ - irupt = timecalc.TimeToMinutes(document.getElementById(wday + "_timestart2" + strappend).value)-timecalc.TimeToMinutes(document.getElementById(wday + "_timeend1" + strappend).value); - document.getElementById(wday + "_interruption" + strappend).value= timecalc.MinutesToTime(irupt); + if ((mt2 > 0) && (mt1 > 0)){ + irupt = timecalc.TimeToMinutes(ods2.value)-timecalc.TimeToMinutes(ode1.value); + oirupt.value=timecalc.MinutesToTime(irupt); + if (irupt > daycheck.maxinterruption){ + oirupt.classList.remove("w3-text-black"); + oirupt.classList.add("w3-text-red"); + }else { + oirupt.classList.remove("w3-text-red") + oirupt.classList.add("w3-text-black"); + } + + } else { + oirupt.classList.remove("w3-text-red"); + oirupt.classList.add("w3-text-black") + oirupt.value="00:00"; + } + owkh.value= timecalc.MinutesToTime(mt1+mt2-mtp); + staffworkplan.checkdaytime(id); + }, + checkdaytime: function(id){ + console.log("set Daytime"); + var pp = id.split("_"); + var wday=pp[0]; + var wktime = 0; + var vactime = 0; + var reptime = 0; + var strappend=''; + var owkh = document.getElementById(wday + "_workhours" + strappend); + var ovach = document.getElementById(wday + "_vacancyhours" + strappend); + var orech = document.getElementById(wday + "_recuperationhours" + strappend); + var odyh =document.getElementById(wday + "_dayhours" + strappend); + if (pp.length > 2){ + strappend = "_" + pp[2]; + } + if (owkh.value){ + console.log("WorkTime:" + owkh.value); + wktime = timecalc.TimeToMinutes(owkh.value); + } + if (ovach.value){ + vactime = timecalc.TimeToMinutes(ovach.value); + } + if (orech.value){ + reptime = timecalc.TimeToMinutes(orech.value); + } + + var fulldaytime = wktime+vactime+reptime; + console.log(wktime+ "+" +vactime + "+" + reptime + "=" + fulldaytime); + odyh.value= timecalc.MinutesToTime(fulldaytime); + + if (fulldaytime > 600){ + //console.log(document.getElementById(wday + "_dayhours" + strappend).value); + odyh.classList.remove("w3-text-black"); + odyh.classList.add("w3-text-red"); }else { - document.getElementById(wday + "_interruption" + strappend).value=""; - } - document.getElementById(wday + "_timetotal" + strappend).value= timecalc.MinutesToTime(mt1+mt2-mtp); - var totaltester = /\d+:\d\d/; - var valcheck= document.getElementById(wday + "_timetotal" + strappend).value; - if (valcheck && valcheck != ''){ - if ((valcheck == '00:00') || (!totaltester.test(valcheck))) { - document.getElementById(wday + "_timetotal" + strappend).value =""; + odyh.classList.remove("w3-text-red"); + odyh.classList.add("w3-text-black"); + } + staffworkplan.checkweektime(); + }, + checkweektime: function(){ + var wdayfields = document.getElementsByClassName("wdaytotal"); + wktotals = 0; + vactotals = 0; + reptotals = 0; + for (var w in wdayfields){ + if (wdayfields[w].value){ + wktotals += timecalc.TimeToMinutes(wdayfields[w].value); } } + document.getElementById("week_workhours").value=timecalc.MinutesToTime(wktotals); + var vacfields = document.getElementsByClassName("vacdaytotal"); + for (var w in vacfields){ + if (vacfields[w].value){ + vactotals += timecalc.TimeToMinutes(vacfields[w].value); + } + } + document.getElementById("week_vacancyhours").value=timecalc.MinutesToTime(vactotals); + var repfields = document.getElementsByClassName("repdaytotal"); + + for (var w in repfields){ + if (repfields[w].value){ + reptotals += timecalc.TimeToMinutes(repfields[w].value); + } + } + document.getElementById("week_recuperationhours").value=timecalc.MinutesToTime(reptotals); }, periodtimesum: function(values, data, calcParams){ - // console.log(values); + + var groupdiv='
'; + // console.log(values); //console.log(data); - calc = 0; - for (var i=0;i 0) && (mt1 > 0)){ + dataupd["interruptionhours"] = timecalc.TimeToMinutes(cd.timestart2)-timecalc.TimeToMinutes(cd.timeend1); + } else { + dataupd["interruptionhours"] = null; + } + dataupd["workhours"] = timecalc.MinutesToTime(mt1+mt2-mtp); + return dataupd; + } +} + +var timeEditor = function(cell, onRendered, success, cancel, editorParams){ + //cell - the cell component for the editable cell + //onRendered - function to call when the editor has been rendered + //success - function to call to pass the successfuly updated value to Tabulator + //cancel - function to call to abort the edit and return to a normal cell + //editorParams - params object passed into the editorParams column definition property + + //create and style editor + var editor = document.createElement("input"); + + editor.setAttribute("type", "text"); + + //create and style input + editor.style.padding = "3px"; + editor.style.width = "100%"; + editor.style.boxSizing = "border-box"; + // flatpickr(editor,{ + // //altInput: true, + // //altFormat: "H:i", + // dateFormat: "H:i", + // //allowInput: true, + // defaultHour:'', + // defaultMinute:'', + // enableTime: true, + // noCalendar: true, + // time_24hr: true, + // "locale": "fr", + // }); + //Set value of editor to the current value of the cell + //editor._flatpickr.setDate(cell.getValue()); + if (cell.getValue()){ + editor.value = cell.getValue(); + } + + + //set focus on the select box when the editor is selected (timeout allows for editor to be added to DOM) + onRendered(function(){ + editor.focus(); + editor.style.css = "100%"; + }); + + //when the value has been set, trigger the cell to update + function successFunc(){ + var editval = editor.value; + editval = timecalc.StringToTime(editval); + success(editval); + } + + editor.addEventListener("change", successFunc); + editor.addEventListener("blur", successFunc); + + //return the editor element + return editor; +}; \ No newline at end of file diff --git a/backoffice/tmpl/module/staff/index.tt b/backoffice/tmpl/module/staff/index.tt index 43c1b730..87738796 100644 --- a/backoffice/tmpl/module/staff/index.tt +++ b/backoffice/tmpl/module/staff/index.tt @@ -73,6 +73,7 @@

Données contractuelles

+
[% fieldhidden("id_staffcontract","staffcontract",'ident','') %] [% fieldhidden("id_staff","staffcontract",'','') %] @@ -80,7 +81,10 @@ [% fielddatebox("enddate","staffcontract","date fin",'w3-half','','') %] [% fieldeditbox("weekhours","staffcontract","heures par semaine","w3-third","","","") %] [% fieldselectbox("weekdays","staffcontract","jours par semaine","w3-third","","","") %] - [% fieldselectbox('id_staffgroup','staffcontract','Département','w3-third','','','') %] +
+ [% fieldselectbox('id_staffgroup','staffcontract','Département','w3-third','','','') %] + [% fieldselectbox('id_workplan','staffcontract','POT (Modèle)','w3-third','','','') %] +