$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};
}
} else {
$html->{result} = "ERROR: no idents!";
}
+ print Dumper($html);
}
elsif (exists($p->{del})){
my $x = $p;
$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}<br/>";
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};
}
$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"){
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())
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?> \r<svg version="1.2" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" \r x="0px" y="0px" width="50px" height="50px" viewBox="0 0 61.8 62.77"> \r<path d="M2.9505676,36.439814L21.343939,36.439814C20.303749,39.110218 19.703638,42.000652 19.703638,45.041111 19.703638,47.101423 19.993691,49.091722 20.493784,50.992008L2.9505676,50.992008C1.3202689,50.992008,2.6905189E-05,49.67181,2.6147463E-05,48.041565L2.6147463E-05,39.400261C2.6905189E-05,37.760014,1.3202689,36.439814,2.9505676,36.439814z M43.691771,27.403506C43.883024,27.398506,44.075529,27.398506,44.270537,27.403506L44.280539,27.403506 44.300539,27.403506C46.750612,27.423509,49.070685,27.943573,51.18075,28.873688L51.25075,28.913692C57.48094,31.684034 61.801073,37.954807 61.73107,45.205702 61.631067,54.946903 53.660826,62.767868 43.920527,62.667858 36.320295,62.587849 29.900101,57.707245 27.500027,50.946411L33.810221,49.846275C35.580275,53.706753 39.450392,56.407085 43.980528,56.457092 50.230719,56.517097 55.340876,51.496479 55.400877,45.245708 55.470881,39.004938 50.450728,33.884306 44.200537,33.824298 43.670519,33.824298 43.150503,33.864304 42.64049,33.924311L42.630488,33.884306C40.950438,34.104332,39.390391,34.694407,38.030348,35.584515L40.200415,37.634769C40.33042,37.754784 40.380419,37.944807 40.310415,38.104826 40.250414,38.274847 40.100412,38.384861 39.920405,38.394863L34.650244,38.674896 29.970102,38.924927 29.940102,38.924927C29.810097,38.924927 29.700094,38.86492 29.61009,38.77491 29.520088,38.674896 29.480087,38.54488 29.510088,38.404863L30.260111,34.234348 31.340143,28.333621C31.370144,28.153599 31.500149,28.013581 31.670155,27.983578 31.850159,27.943573 32.030165,28.013581 32.130167,28.1636L33.86022,30.703914C36.260294,28.9737 39.11038,27.853561 42.200476,27.513519 42.240477,27.503518 42.280478,27.503518 42.320479,27.503518 42.590487,27.473515 42.850496,27.453512 43.120504,27.43351 43.310507,27.418509 43.500513,27.408506 43.691771,27.403506z M2.9499468,18.059961L44.308165,18.059961C45.938101,18.059961,47.268,19.380206,47.268,21.020318L47.268,21.830486C45.968126,21.610486 44.638106,21.470574 43.278181,21.470575 34.818579,21.470574 27.428881,25.931133 23.269024,32.611961L2.9499468,32.611961C1.3200119,32.611961,-1.251392E-07,31.291716,0,29.661614L0,21.020318C-1.251392E-07,19.380206,1.3200119,18.059961,2.9499468,18.059961z M8.6996557,3.927825C6.8497344,3.927825 5.3397986,5.4269943 5.3397986,7.2759705 5.3397986,9.1249466 6.8497344,10.634111 8.6996557,10.634111 10.549576,10.634111 12.049512,9.1249466 12.049512,7.2759705 12.049512,5.4269943 10.549576,3.927825 8.6996557,3.927825z M2.949901,0L44.308134,0C45.938063,0,47.268007,1.3292637,47.268007,2.9583616L47.268007,11.603574C47.268007,13.232672,45.938063,14.551941,44.308134,14.551941L2.949901,14.551941C1.3199705,14.551941,2.6895254E-05,13.232672,2.6147463E-05,11.603574L2.6147463E-05,2.9583616C2.6895254E-05,1.3292637,1.3199705,0,2.949901,0z"/> \r</svg>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?> \r
+<svg version="1.2" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" \r
+ x="0px" y="0px" width="50px" height="50px" viewBox="0 0 61.8 62.77"> \r
+<path fill="#fff" d="M2.9505676,36.439814L21.343939,36.439814C20.303749,39.110218 19.703638,42.000652 19.703638,45.041111 19.703638,47.101423 19.993691,49.091722 20.493784,50.992008L2.9505676,50.992008C1.3202689,50.992008,2.6905189E-05,49.67181,2.6147463E-05,48.041565L2.6147463E-05,39.400261C2.6905189E-05,37.760014,1.3202689,36.439814,2.9505676,36.439814z M43.691771,27.403506C43.883024,27.398506,44.075529,27.398506,44.270537,27.403506L44.280539,27.403506 44.300539,27.403506C46.750612,27.423509,49.070685,27.943573,51.18075,28.873688L51.25075,28.913692C57.48094,31.684034 61.801073,37.954807 61.73107,45.205702 61.631067,54.946903 53.660826,62.767868 43.920527,62.667858 36.320295,62.587849 29.900101,57.707245 27.500027,50.946411L33.810221,49.846275C35.580275,53.706753 39.450392,56.407085 43.980528,56.457092 50.230719,56.517097 55.340876,51.496479 55.400877,45.245708 55.470881,39.004938 50.450728,33.884306 44.200537,33.824298 43.670519,33.824298 43.150503,33.864304 42.64049,33.924311L42.630488,33.884306C40.950438,34.104332,39.390391,34.694407,38.030348,35.584515L40.200415,37.634769C40.33042,37.754784 40.380419,37.944807 40.310415,38.104826 40.250414,38.274847 40.100412,38.384861 39.920405,38.394863L34.650244,38.674896 29.970102,38.924927 29.940102,38.924927C29.810097,38.924927 29.700094,38.86492 29.61009,38.77491 29.520088,38.674896 29.480087,38.54488 29.510088,38.404863L30.260111,34.234348 31.340143,28.333621C31.370144,28.153599 31.500149,28.013581 31.670155,27.983578 31.850159,27.943573 32.030165,28.013581 32.130167,28.1636L33.86022,30.703914C36.260294,28.9737 39.11038,27.853561 42.200476,27.513519 42.240477,27.503518 42.280478,27.503518 42.320479,27.503518 42.590487,27.473515 42.850496,27.453512 43.120504,27.43351 43.310507,27.418509 43.500513,27.408506 43.691771,27.403506z M2.9499468,18.059961L44.308165,18.059961C45.938101,18.059961,47.268,19.380206,47.268,21.020318L47.268,21.830486C45.968126,21.610486 44.638106,21.470574 43.278181,21.470575 34.818579,21.470574 27.428881,25.931133 23.269024,32.611961L2.9499468,32.611961C1.3200119,32.611961,-1.251392E-07,31.291716,0,29.661614L0,21.020318C-1.251392E-07,19.380206,1.3200119,18.059961,2.9499468,18.059961z M8.6996557,3.927825C6.8497344,3.927825 5.3397986,5.4269943 5.3397986,7.2759705 5.3397986,9.1249466 6.8497344,10.634111 8.6996557,10.634111 10.549576,10.634111 12.049512,9.1249466 12.049512,7.2759705 12.049512,5.4269943 10.549576,3.927825 8.6996557,3.927825z M2.949901,0L44.308134,0C45.938063,0,47.268007,1.3292637,47.268007,2.9583616L47.268007,11.603574C47.268007,13.232672,45.938063,14.551941,44.308134,14.551941L2.949901,14.551941C1.3199705,14.551941,2.6895254E-05,13.232672,2.6147463E-05,11.603574L2.6147463E-05,2.9583616C2.6895254E-05,1.3292637,1.3199705,0,2.949901,0z"/> \r
+</svg>
\ No newline at end of file
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){
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) {
},
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 "";
}
}
--- /dev/null
+<!-- <div class="w3-display-container w3-padding-24 panel" id="pnl_frm_staffworkplan_edit" style=" margin-top: 20px;display: none;">
+ <div class="w3-container w3-padding-24 w3-card w3-margin w3-margin-bottom">
+ <form id="frm_staffworkplan_edit">
+ <h3>Plan de travail</h3>
+ <div class="w3-row-padding">
+ <div class="w3-container">
+
+ <div class="w3-container w3-padding">
+ [% fieldhidden('id_staff','staffworkplan','') %]
+
+ [% fieldeditbox('dspstaffname','staffworkplan','Salarié','w3-half','readonly','') %]
+ [% fieldselectbox('id_workplan','staffworkplan','Changer Modèle POT','w3-third','','','') %]
+
+ </div>
+ <div class="w3-container w3-card w3-padding">
+ <h4 id="week_title">Semaine</h4>
+ <div class="w3-row">
+ <div class="w3-container">
+ [% fieldtimebox("week_workhours",'display',"Total POT",'w3-fifth','readonly','') %]
+ [% fieldtimebox("week_vacancyhours",'display',"Total Congé",'w3-fifth','readonly','') %]
+ [% fieldtimebox("week_recuperationhours",'display',"Total Récup",'w3-fifth','readonly','') %]
+ [% fieldtimebox("week_hoursdiff",'display',"Nouv. à récup.",'w3-fifth','readonly','') %]
+ [% fieldtimebox("week_hoursrestbefore",'display',"à récup. d'avant",'w3-fifth','readonly','') %]
+ </div>
+ </div>
+ </div>
+
+ [% FOREACH tt IN wd %]
+ [% wday = tt.wd %]
+ [% headday = tt.day %]
+ <div class="w3-container w3-card w3-padding">
+ <h4 id="[% wday%]_title">[% headday %]</h4>
+ <div class="w3-row">
+ <div class="w3-container w3-third">
+ <h5>POT</h5>
+ <div class="w3-container">
+ [% fieldhidden("${wday}_id",'staffworkplan','') %]
+ [% fieldhidden("${wday}_daydate",'staffworkplan','') %]
+ [% fieldtimebox("${wday}_timestart1",'staffworkplan','début 1','w3-fifth','','') %]
+ [% fieldtimebox("${wday}_timeend1",'staffworkplan','fin 1','w3-fifth','','') %]
+ </div>
+ <div class="w3-container">
+ [% fieldtimebox("${wday}_timestart2",'staffworkplan','début 2','w3-fifth','','') %]
+ [% fieldtimebox("${wday}_timeend2",'staffworkplan','fin 2','w3-fifth','','') %]
+ [% fieldtimebox("${wday}_timepause",'staffworkplan','pause','w3-fifth','','') %]
+ </div>
+ <div class="w3-container">
+ [% fieldtimebox("${wday}_workhours",'staffworkplan',"Total",'w3-fifth','readonly','') %]
+ [% fieldtimebox("${wday}_interruptionhours",'staffworkplan','coupure','','readonly','') %]
+ </div>
+ </div>
+ <div class="w3-container w3-third card_vacancy">
+
+ <div class="w3-container">
+ <h5>Congé</h5>
+ [% fieldselectbox("${wday}_id_vacancytype",'staffworkplan','Type de congé','w3-half','','','dayvacancy') %]
+ [% fieldtimebox("${wday}_vacancyhours",'staffworkplan','Heures','w3-half','','','vacdaytotal') %]
+ </div>
+
+ <div class="w3-container">
+ <h5>Repos</h5>
+ [% fieldselectbox("${wday}_id_recuperationtype",'staffworkplan','type de repos','w3-half','','','dayrepos') %]
+ [% fieldtimebox("${wday}_recuperationhours",'staffworkplan','Heures','w3-half','','','repdaytotal') %]
+ </div>
+
+ </div>
+ <div class="w3-container w3-third card_totals">
+ <div class="w3-container">
+ <h5>Total Jour</h5>
+ [% fieldtimebox("${wday}_dayhours",'staffworkplan','Total Jour','','readonly','','wdaytotal') %]
+ </div>
+ </div>
+ <!-- <div class="w3-container w3-third card_stamp">
+ <h5>Pointages</h5>
+ <div id="tbl_[% wday %]_stamp"></div>
+ </div> -->
+ </div>
+ </div>
+ [% END %]
+ </div>
+ <div class="w3-container w3-right-align">
+ <button class="w3-button w3-blue-grey w3-margin" id="btnsave_staffworkplan_edit" onclick="staffworkplan.save_edit();return false;">sauvegarder</button>
+ </div>
+ </div>
+ </form>
+ </div>
+
+ </div> -->
\ No newline at end of file
--- /dev/null
+[% PROCESS macro/fields.tt %]
+<div id="dlgaction" class="w3-modal">
+
+ <div class="w3-modal-content w3-animate-top w3-card-4">
+ <header class="w3-container">
+ <span onclick="document.getElementById('dlgaction').style.display='none'; return false;"
+ class="w3-button w3-display-topright">×</span>
+ <h2 id="dlgaction_title"></h2>
+ </header>
+ <div class="w3-container">
+ <span id="dlgaction_message"></span>
+ [% fieldhidden("dlgactionschema","action",'','') %]
+ [% fieldhidden("dlgactionfunction","action",'','') %]
+ [% fieldhidden("dlgparams","action",'','') %]
+ </div>
+ <footer class="w3-container w3-right-align w3-padding-16">
+ <button class="w3-button w3-theme-light w3-margin-right w3-border" onclick="document.getElementById('dlgaction').style.display='none'; return false;">Annuler</button>
+ <button class="w3-button w3-red w3-margin-right w3-border" id="btnaction" onclick="action_confirmed();">Oui</button>
+ </footer>
+ </div>
+</div>
+<script>
+var afteractioncallback = null;
+
+function showactiondlg(actschema,actfunction,acttitle,actmessage,actcallback,actparams){
+ if (actmessage){
+ document.getElementById('dlgaction_message').innerHTML = actmessage;
+ }
+ if (acttitle){
+ document.getElementById('dlgaction_title').innerHTML = acttitle;
+ }
+
+ document.getElementById('dlgactionschema').value=actschema;
+ document.getElementById('dlgactionfunction').value=actfunction;
+ document.getElementById('dlgparams').value=actparams;
+ afteractioncallback = actcallback;
+ document.getElementById('dlgaction').style.display='block';
+ return false;
+}
+
+function action_confirmed(){
+ //var deltbl = "ident_"+ document.getElementById('dlgdeltable').value + "_id";
+ req.reqdata("POST", "db.cgi", {
+ "action": document.getElementById('dlgactionfunction').value,
+ "schemata": document.getElementById('dlgactionschema').value,
+ "params": document.getElementById('dlgparams').value
+ }, afteraction);
+ document.getElementById('dlgaction_message').innerHTML ="";
+ document.getElementById('dlgaction_title').innerHTML ="";
+ document.getElementById('dlgactionschema').value="";
+ document.getElementById('dlgactionfunction').value="";
+ document.getElementById('dlgparams').value="";
+ return false;
+}
+
+function afteraction(){
+
+ if (afteractioncallback != null){
+ //console.log("lauch after callback");
+ //console.log(afterdeletecallback);
+ afteractioncallback(null);
+ }
+ document.getElementById('dlgaction').style.display='none';
+ var sb = document.getElementById("snackbar");
+ sb.className="show w3-green";
+ sb.innerHTML = 'Les données ont été sauvegardées!';
+ setTimeout(function(){ sb.className = sb.className.replace("show w3-green", ""); }, 3000);
+ afterdeletecallback =null;
+ return false;
+}
+</script>
\ No newline at end of file
</div>\r
</div>\r
[% END -%]\r
-[% MACRO fieldtimebox(column,table,title,size,state,value) BLOCK -%]\r
+[% MACRO fieldtimebox(column,table,title,size,state,value,class) BLOCK -%]\r
<div class="w3-container w3-col" style="width: 120px;">\r
<label for="[% table %]_[% column %]" class="w3-label">[% title %]</label>\r
<div class="w3-container">\r
[% IF state == "disabled" || state == "readonly" %]\r
- <input type="text" class="w3-input w3-border data_[% table %] w3-white w3-text-black" style="max-width: 60px; width: 60px;" id="[% column %]" name="[% table %]_[% column %]" maxlength="5" value="[% value %]" readonly/>\r
+ <input type="text" class="w3-input w3-border data_[% table %] w3-white w3-text-black [% IF class %][% class %][% END %]" style="max-width: 60px; width: 60px;" id="[% column %]" name="[% table %]_[% column %]" maxlength="5" value="[% value %]" readonly/>\r
[% ELSE %]\r
- <input type="text" class="w3-input-append w3-border data_[% table %] timefield" style="max-width: 60px; width: 60px;" id="[% column %]" name="[% table %]_[% column %]" maxlength="5" placeholder="00:00" value="[% value %]"/>\r
+ <input type="text" class="w3-input-append w3-border data_[% table %] timefield [% IF class %][% class %][% END %]" style="max-width: 60px; width: 60px;" id="[% column %]" name="[% table %]_[% column %]" maxlength="5" placeholder="00:00" value="[% value %]"/>\r
<a class="w3-btn w3-text-red w3-border" style="padding: 4px 8px;" onclick="document.getElementById('[% column %]').value='';document.getElementById('[% column %]')._flatpickr.clear();return false;">x</a>\r
\r
[% END %]\r
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();
},
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);
[% PROCESS macro/fields.tt %]
+
<div class="w3-display-container">
<div class="w3-top w3-theme-light w3-border-bottom">
<div class="w3-bar">
[% fieldeditbox('vatnumber','companies','No TVA Internationale','w3-third','','','LU12345678') %]
</div>
[% fieldeditbox('email','companies','E-Mail','w3-half','','','') %]
+ [% rdonly = 'readonly' %]
+ [% IF (session.usergroup == 'admin') %]
+ [% fieldeditbox('schemata','companies','Database-Schema','w3-half','readonly','','') %]
+ [% rdonly = '' %]
+ [% END %]
+ <div class="w3-container">
+ <h5>Configuration Périodes</h5>
+ [% 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) %]
+ </div>
</div>
- [% IF (session.usergroups.search('admin') == 1) %]
- [% fieldeditbox('schemata','companies','Database-Schema','w3-half','readonly','','') %]
- [% END %]
+
+
</div>
<div class="w3-container w3-right-align">
<button class="w3-button w3-blue-grey w3-margin" id="btnsave_companies" onclick="companies.save();return false;">sauvegarder</button>
columns: [{
title: "Département",
field: "groupname"
- }]
+ },{
+ title: "Groupe standard",
+ field: "isdefault",formatter:"tickCross", formatterParams:{
+ allowEmpty:true,
+ allowTruthy:true,
+ tickElement:'<span style="color: green;">✔</span>',
+ crossElement:'<span style="color: red;">×</span>',
+}
+}]
});
staffgroups.gettbldata();
},
console.log("Current Schema:" + schemata);
reportperiod.inittable();
staffworkplan.inittable();
+ //staffworkplan_daily.inittable();
module.viewpanel("tbl_reportperiod");
//call("reportperiod","inittable");
src="[% abspath%]img/icons/poticon.svg" style="height: 24px;" /></button>
<button class="w3-bar-item w3-button w3-border w3-right" onclick="reportperiod.generatereport();"><img
src="[% abspath%]img/icons/pdf.svg" style="height: 24px;" /></button>
+ <button class="w3-bar-item w3-button w3-border w3-right" onclick="reportperiod.datarefresh();"><img
+ src="[% abspath%]img/icons/data_refresh.svg" style="height: 24px;" /></button>
</div>
<div class="toolbar" id="tbar_tbl_staffworkplan" style="display: none;">
<span id="reportperiodtitle"></span>
<button class="w3-bar-item w3-button w3-border w3-right w3-blue-grey" onclick="staffworkplan.edit();"><img src="[% abspath%]img/icons/edit_white.svg" style="height: 24px;"/></button>
<button class="w3-bar-item w3-button w3-border w3-right w3-blue-grey" onclick="staffworkplan.add();"><img src="[% abspath%]img/icons/plus_white.svg" style="height: 24px;"/></button>
</div>
+ <div class="toolbar" id="tbar_tbl_daystaffworkplan" style="display: none;">
+ <span id="reportperiodtitle2"></span>
+ <button class="w3-bar-item w3-button w3-border w3-blue-grey w3-hover-text-white" onclick="module.viewpanel('tbl_weekworkplan');">retour vers POT Semaine</button>
+ <button class="w3-bar-item w3-button w3-border w3-right w3-blue-grey" onclick="staffworkplan.save();"><img src="[% abspath%]img/icons/save_white.svg" style="height: 24px;"/></button>
+ </div>
<div class="toolbar" id="tbar_frm_staffworkplan" style="display: none;">
- <button class="w3-bar-item w3-button w3-border w3-blue-grey w3-hover-text-white" onclick="module.viewpanel('tbl_staffworkplan');">retour vers le Plan</button>
+ <button class="w3-bar-item w3-button w3-border w3-blue-grey w3-hover-text-white" onclick="module.viewpanel('tbl_weekworkplan');">retour vers POT Semaine</button>
</div>
- <div class="toolbar" id="tbar_frm_staffworkplan_edit" style="display: none;">
- <button class="w3-bar-item w3-button w3-border w3-blue-grey w3-hover-text-white" onclick="module.viewpanel('tbl_staffworkplan');">retour vers le Plan</button>
+ <div class="toolbar" id="tbar_frm_staffworkplan_edit" style="display: none;">
+ <button class="w3-bar-item w3-button w3-border w3-blue-grey w3-hover-text-white" onclick="module.viewpanel('tbl_staffworkplan');">retour vers POT Semaines</button>
</div>
<div class="toolbar" id="tbar_frm_staffworkplan_add" style="display: none;">
- <button class="w3-bar-item w3-button w3-border w3-blue-grey w3-hover-text-white" onclick="module.viewpanel('tbl_staffworkplan');">retour vers le Plan</button>
+ <button class="w3-bar-item w3-button w3-border w3-blue-grey w3-hover-text-white" onclick="module.viewpanel('tbl_staffworkplan');">retour vers POT Semaines</button>
</div>
</div>
</div>
<div class="w3-display-container panel" id="pnl_tbl_staffworkplan" style="margin-top: 45px;">
<div id="tbl_staffworkplan"></div>
</div>
+
<!-- Edit Plan begin -->
<div class="w3-display-container w3-padding-24 panel" id="pnl_frm_staffworkplan_edit" style=" margin-top: 20px;display: none;">
<div class="w3-container w3-padding-24 w3-card w3-margin w3-margin-bottom">
[% fieldselectbox('id_workplan','staffworkplan','Changer Modèle POT','w3-third','','','') %]
</div>
+ <div class="w3-container w3-card w3-padding">
+ <h4 id="week_title">Semaine</h4>
+ <div class="w3-row">
+ <div class="w3-container">
+
+ [% fieldtimebox("week_workhours",'display',"Total POT",'w3-fifth','readonly','') %]
+ [% fieldtimebox("week_vacancyhours",'display',"Total Congé",'w3-fifth','readonly','') %]
+ [% fieldtimebox("week_recuperationhours",'display',"Total Récup",'w3-fifth','readonly','') %]
+ [% fieldtimebox("week_hoursdiff",'display',"Nouv. à récup.",'w3-fifth','readonly','') %]
+ [% fieldtimebox("week_hoursrestbefore",'display',"à récup. d'avant",'w3-fifth','readonly','') %]
+ </div>
+ </div>
+ </div>
[% FOREACH tt IN wd %]
[% wday = tt.wd %]
[% fieldhidden("${wday}_daydate",'staffworkplan','') %]
[% fieldtimebox("${wday}_timestart1",'staffworkplan','début 1','w3-fifth','','') %]
[% fieldtimebox("${wday}_timeend1",'staffworkplan','fin 1','w3-fifth','','') %]
- [% fieldtimebox("${wday}_timepause",'staffworkplan','pause','w3-fifth','','') %]
</div>
<div class="w3-container">
[% 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','','') %]
+ </div>
+ <div class="w3-container">
+ [% fieldtimebox("${wday}_workhours",'staffworkplan',"Total",'w3-fifth','readonly','') %]
+ [% fieldtimebox("${wday}_interruptionhours",'staffworkplan','coupure','','readonly','') %]
</div>
</div>
<div class="w3-container w3-third card_vacancy">
+
+ <div class="w3-container">
<h5>Congé</h5>
- [% 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') %]
+ </div>
+
+ <div class="w3-container">
+ <h5>Repos</h5>
+ [% fieldselectbox("${wday}_id_recuperationtype",'staffworkplan','type de repos','w3-half','','','dayrepos') %]
+ [% fieldtimebox("${wday}_recuperationhours",'staffworkplan','Heures','w3-half','','','repdaytotal') %]
+ </div>
+
</div>
- <div class="w3-container w3-third card_stamp">
- <h5>Pointages</h5>
- <div id="tbl_${wday}_stamp"></div>
+ <div class="w3-container w3-third card_totals">
+ <div class="w3-container">
+ <h5>Total Jour</h5>
+ [% fieldtimebox("${wday}_dayhours",'staffworkplan','Total Jour','','readonly','','wdaytotal') %]
+ </div>
</div>
+ <!-- <div class="w3-container w3-third card_stamp">
+ <h5>Pointages</h5>
+ <div id="tbl_[% wday %]_stamp"></div>
+ </div> -->
+ </div>
</div>
+ [% END %]
+ </div>
+ <div class="w3-container w3-right-align">
+ <button class="w3-button w3-blue-grey w3-margin" id="btnsave_staffworkplan_edit" onclick="staffworkplan.save_edit();return false;">sauvegarder</button>
</div>
- [% END %]
- </div>
- <div class="w3-container w3-right-align">
- <button class="w3-button w3-blue-grey w3-margin" id="btnsave_staffworkplan_edit" onclick="staffworkplan.save_edit();return false;">sauvegarder</button>
</div>
- </div>
- </form>
- </div>
-
- </div>
+ </form>
+ </div>
+
+ </div>
+ <!-- And edit plan -->
<!-- Add Plan begin -->
<div class="w3-display-container w3-padding-24 panel" id="pnl_frm_staffworkplan_add" style=" margin-top: 20px;display: none;">
<div class="w3-container w3-padding-24 w3-card w3-margin w3-margin-bottom">
[% fieldtimebox("${wday}_timestart2_add",'staffworkplan_add','début 2','','','') %]
[% fieldtimebox("${wday}_timeend2_add",'staffworkplan_add','fin 2','','','') %]
[% fieldtimebox("${wday}_interruption_add",'satffaworkplan_add','coupure','','readonly','') %]
- [% fieldtimebox("${wday}_timetotal_add",'staffworkplan_add',"Total",'','readonly','') %]
+ [% fieldtimebox("${wday}_workhours_add",'staffworkplan_add',"Total",'','readonly','') %]
</div>
</div>
<div class="w3-modal-content w3-animate-top w3-card-4">
<header class="w3-container">
<span onclick="document.getElementById('dlg_reportperiod').style.display='none'; return false;" class="w3-button w3-display-topright">×</span>
- <h2 id="dlgdelete_title">editer/ajouter période</h2>
+ <h2 id="dlgdelete_title">editer période</h2>
</header>
<div class="w3-container">
<div id="reportperiod_infomsg"></div>
<form id="frm_reportperiod">
[% fieldhidden("id","reportperiod",'ident','') %]
- [% fieldhidden("enddate","reportperiod",'','') %]
- <div class="w3-cell-row">
- [% fieldeditbox("periodname","reportperiod","Nom",'','','','') %]
- </div>
+ [% #fieldhidden("enddate","reportperiod",'','') %]
+ <!-- <div class="w3-cell-row"> -->
+ [% #fieldeditbox("periodname","reportperiod","Nom",'','','','') %]
+ <!-- </div> -->
<div class="w3-cell-row">
- [% fieldselectbox("id_staffgroup","reportperiod","Département",'w3-half','','','') %]
+ [% #fieldselectbox("id_staffgroup","reportperiod","Département",'w3-half','','','') %]
</div>
<div class="w3-cell-row">
- [% 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','','') %]
</div>
- [% IF session.usergroup.search("manager") == 1 || session.usergroup.search("teamleader") == 1 || session.usergroup.search("admin") == 1 %]
+ [% IF session.usergroup == "manager" || session.usergroup == "admin" %]
<div class="w3-cell-row">
[% fieldcheckbox("isvalidated","reportperiod","Validé",'','','1') %]
[% fieldhidden("id_validateuser","reportperiod",'','') %]
[% INCLUDE block/dlgmessage.tt %]
[% INCLUDE block/dlgdataload.tt %]
[% INCLUDE block/dlgreport.tt %]
+ [% INCLUDE block/dlgaction.tt %]
<script src="reportperiod.js"></script>
- <script src="staffworkplan.js"></script>
\ No newline at end of file
+ <script src="staffworkplan.js"></script>
+ <script src="staffworkplan_daily.js"></script>
\ No newline at end of file
// // ],
// "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, {
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:'<span class="strong w3-text-green">✔</span>',crossElement:'<span class="strong w3-text-red">☓</span>'}},
{ title: "Verfifié par",field: "userdisplayname",formatter:"plaintext" },
]
},
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(){
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 == ''){
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;
}
}
// 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('','<div class="w3-xxlarge">Attendez s.v.p.!</div>');
+ req.reqdata("POST","db.cgi",{"action":"refreshperiods","schemata":schemata,"params":""},reportperiod.datarefreshdone);
+ return false;
+ },
+ datarefreshdone(){
+ closedataloaddlg();
+ return false;
}
}
\ No newline at end of file
//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",{
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,
// 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<tfields.length;i++){
- tfields[i].addEventListener("change",function(){staffworkplan.checktime(this.id);});
+
+ //console.log(tfields[i]);
+ if (tfields[i].id.endsWith("vacancyhours") || tfields[i].id.endsWith("recuperationhours") || tfields[i].id.endsWith("workhours")){
+ console.log("timefield:" + tfields[i].id + "=> 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<vfields.length;i++){
vfields[i].addEventListener('change', function(event){staffworkplan.setvacancyhours(event,this.id);});
//
}
+ var vfields = document.getElementsByClassName("dayrepos");
+ for (var i=0;i<vfields.length;i++){
+ //console.log(vfields[i]);
+ vfields[i].addEventListener('change', function(event){staffworkplan.setrecuperationhours(event,this.id);});
+ //
+ }
},
inittable: function(){
staffworkplan.initform();
staffworkplan.tbl = new Tabulator("#tbl_" + staffworkplan.name, {
//headerFilterPlaceholder: "filter...",
height: "94vh",
- layout: "fitData",
+ layout: "fitDataFill",
selectable: 1,
rowContext:function(e, row){
//e - the click event object
//contextMenu.addSeperator();
e.preventDefault(); // prevent the browsers default context menu form appearing.
},
- groupBy:["staffname"],
+ renderComplete:function(){
+ //var grps = staffworkplan.tbl.getGroups()
+ pdata = document.getElementsByClassName("perioddata");
+ for (var p in pdata){
+ pdata[p].innerHTML = 'TEST';
+ }
+ // for (g in grps){
+ // console.log(grps[g]);
+ // //console.log(grps[g]);
+ // console.log(grps[g]._group.calcs.bottom.data.dspweektotals);
+ // //grps[g]._group.calcs.bottom.data.dspweektotals = "TEST";
+ // }
+ console.log("TABLE rendered!");
+ },
+ groupBy:["dspstaffname"],
groupStartOpen:[true],
groupClosedShowCalcs:true,
groupHeader:[
function(value, count, data){ //generate header contents for gender groups
- return value;
+ return value;
},
- ],
+ ],
columns: [
{ title: "Nom", field: "staffname",width:0,visible: false},
- { title: "Semaine", field:"dspcalweek",formatter: "html",width:120},
- { title: "Total<br/>à réc.", field:"week_contractdiff" },
- { title: "Total<br/>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<br/>à 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<br/>Semaine", field:"dspweektotals",formatter: "html", bottomCalc:staffworkplan.periodtimesum,bottomCalcFormatter:"html"},
]
});
staffworkplan.gettbldata();
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;
},
},
edit: function(){
+ //staffworkplan_daily.gettbldata();
+ // module.viewpanel('tbl_daystaffworkplan');
var udata = staffworkplan.tbl.getSelectedData();
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(){
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)!<br/>";
- // }
- // if (wpdata["staffworkplan_dates"] == "" && wpdata["staffworkplan_daterange"] == ""){
- // datamsg += "pas de date(s) définie(s)!<br/>";
- // }
- // 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)!<br/>"
- // }
- // if (datamsg != ""){
- // showmessagedlg("Configuration incomplète!",'<div class="w3-panel w3-text-red">'+ datamsg+'</div>');
- // return false;
- // }
+
var allrows=[];
showdataloaddlg('','<div class="w3-xxlarge">Attendez s.v.p.!</div>');
for (var w in weekdays){
}
}
- 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");
}
if (wpdata){
- console.log(wpdata);
+ //console.log(wpdata);
}
if (!wpdata["staffworkplan_id_staff"]){
datamsg += "pas d'employé(es) défini(es)!<br/>";
}
var ttlcnt = 0;
for (var f in wpdata){
- if (f.endsWith("timetotal")){
+ if (f.endsWith("workhours")){
if (wpdata[f] != ""){
ttlcnt++;
}
}
}
- console.log("End Prepare Data!");
+ //console.log("End Prepare Data!");
//console.log(allrows)
for (var r in allrows){
allrows[r]["upsert"] = "1";
},
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);
//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];
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()
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("_");
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='<div class="perioddata"></div>';
+ // console.log(values);
//console.log(data);
- calc = 0;
- for (var i=0;i<values.length;i++){
- calc= calc + parseInt(data[i].weekminutes)
- }
+ // calc = 0;
+ // for (var i=0;i<values.length;i++){
+ // calc= calc + parseInt(data[i].weekminutes)
+ // }
- return timecalc.MinutesToTime(calc);
+ return groupdiv;
},
workplansaved: function(data){
console.log(data);
--- /dev/null
+var staffworkplan_daily = {
+ tbl: null,
+ name:"staffworkplan_daily",
+ initform: function(){
+
+ },
+ inittable: function(){
+ staffworkplan_daily.tbl = new Tabulator("#tbl_daystaffworkplan", {
+ height: "94vh",
+ layout: "fitData",
+
+ selectable: 1,
+ rowContext:function(e, row){
+
+ e.preventDefault(); // prevent the browsers default context menu form appearing.
+ },
+ cellEdited:function(cell){
+ //cell - cell component
+ console.log(cell.getData());
+ var upddata = staffworkplan_daily.calchours(cell.getData());
+ staffworkplan_daily.tbl.updateData(upddata);
+ },
+ dataEdited:function(data){
+ console.log(data);
+ //data - the updated table data
+ },
+ columns:[
+ {title:"Jour",field:"daydate",formatter:"datetime",formatterParams:{inputFormat:"YYYY-MM-DD",outputFormat:"dddd",invalidPlaceholder:""}},
+ {title: "Date",field:"daydate",formatter:"datetime",formatterParams:{inputFormat:"YYYY-MM-DD",outputFormat:"DD.MM.YYYY",invalidPlaceholder:""}},
+ {title: "Travail",
+ columns: [
+ {title:"Début 1",field:"starttime1",editor:timeEditor},
+ {title:"Fin 1",field:"endtime1",editor:timeEditor},
+ {title:"Début 2",field:"starttime2",editor:timeEditor},
+ {title:"Fin 2",field:"endtime1",editor:timeEditor},
+ {title:"Pause",field:"timepause",editor:timeEditor},
+ {title:"Coupure",field:"interruptionhours"},
+ {title:"Total",field:"workhours"},
+ ]
+ },
+ {title: "Récuperation",
+ columns:[
+ {title:"Type",field:"id_recuperationtype"},
+ {title:"Heures",field:"recuperationhours"}
+ ]
+ },
+ {title: "Congé",
+ columns:[
+ {title:"Type",field:"id_vacancytype"},
+ {title:"Heures",field:"vacancyhours"}
+ ]
+ },
+ {title: "Totaux",
+ columns:[
+ {title:"travail",field:"dayhours"},
+ {title:"à récupérer",field:"dayhours"}
+ ]
+ }
+ ]
+ });
+
+ },
+ gettbldata: function(){
+ var rpdata = reportperiod.tbl.getSelectedData();
+ var staffdata = staffworkplan.tbl.getSelectedData();
+ req.reqdata("POST", "db.cgi", { "get": staffworkplan_daily.name + "list","schemata":schemata,"filter": "id_staff="+staffdata[0].id_staff+" and id_reportperiod=" + rpdata[0].id }, staffworkplan_daily.loadtbldata);
+ return false;
+ },
+ loadtbldata: function(data){
+ if (data && data.sqldata) { staffworkplan_daily.tbl.setData(data.sqldata);}
+ return false;
+ },
+ save: function(){
+
+ },
+ verify: function(){
+
+ },
+ calchours: function(cd){
+ var mt1 = 0;
+ var mt2 = 0;
+ var mp = 0;
+ dataupd = {"id":cd.id};
+
+ if ((cd.starttime1 != null) && (cd.endtime1 != null)){
+ mt1 = timecalc.TimeToMinutes(cd.endtime1)-timecalc.TimeToMinutes(cd.starttime1);
+ }
+ if ((cd.starttime2 != null) && (cd.endtime2 != null)){
+ mt2 = timecalc.TimeToMinutes(cd.endtime2)-timecalc.TimeToMinutes(cd.starttime2);
+ }
+ if (cd.timepause != null){
+ mtp = timecalc.TimeToMinutes(cd.timepause);
+ }
+ if ((mt2 > 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
<h3 id="dlgstaffcontract_title">Données contractuelles</h3>
</header>
<div class="w3-container">
+ <div id="contractmsg"></div>
<form id="frm_staffcontract">
[% fieldhidden("id_staffcontract","staffcontract",'ident','') %]
[% fieldhidden("id_staff","staffcontract",'','') %]
[% 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','','','') %]
+ <div class="w3-container">
+ [% fieldselectbox('id_staffgroup','staffcontract','Département','w3-third','','','') %]
+ [% fieldselectbox('id_workplan','staffcontract','POT (Modèle)','w3-third','','','') %]
+ </div>
</form>
</div>
<footer class="w3-container w3-right-align w3-padding-16">
var staffcontract = {
name: "staffcontract",
tbl: null,
- choices:{"id_staffgroup":null,"weekdays":null},
+ choices:{"id_staffgroup":null,"weekdays":null,"id_workplan":null},
initform: function(){
staffcontract.choices["id_staffgroup"] = new Choices('#id_staffgroup',{
searchEnabled: false,
itemSelectText: '',
- removeItemButton: true,
+ removeItemButton: false,
+ choices : []
+ });
+ staffcontract.choices["id_workplan"] = new Choices('#id_workplan',{
+ searchEnabled: false,
+ itemSelectText: '',
+ removeItemButton: false,
choices : []
});
staffcontract.choices["weekdays"] = new Choices('#weekdays',{
headerSort: false,
formatter:"money",formatterParams:{decimal:",",thousand:".",symbol:" ",symbolAfter:"",precision:0},
+ },{
+ title: "POT(modèle)",
+ field: "workplan",
+ headerSort: false,
}]
});
staffcontract.getstaffgroups();
+ staffcontract.getwptemplates();
},
gettbldata: function(){
req.reqdata("POST", "db.cgi", { "get": "staffcontractlist","schemata":schemata,"filter":"id_staff='"+ staff.current_id +"'"}, staffcontract.loadtbldata);
}
},
add: function(){
+ document.getElementById("contractmsg").innerHTML="";
cleanform2("staffcontract",staffcontract.choices);
module.viewdialog(staffcontract.name);
document.getElementById("id_staff").value=staff.current_id;
//module.viewpanel('frm_' + users.name);
},
edit: function(){
+ document.getElementById("contractmsg").innerHTML=""
//var selectedRow = staffcontract.tbl.getSelectedRows();
//console.log(selectedRow);
//document.getElementById("company").removeEventListener('blur',function(){},true);
},
remove: function(){
var udata = staffcontract.tbl.getSelectedData();
+ var selrow = staffcontract.tbl.getSelectedRows();
+ console.log(selrow);
if (udata[0]) {
var uid = udata[0].id;
showdeletedlg(staffcontract.name,uid,"Êtes vous sûre de supprimer les données sélectionnées?",staffcontract.afterdeletecallback,schemata);
}
},
save: function(){
+
var flds=getformcontent('staffcontract',null);
+ console.log(flds);
+ flds["ident_staffcontract_id"] = flds["ident_staffcontract_id_staffcontract"];
+ delete flds["ident_staffcontract_id_staffcontract"];
+ delete flds["null"];
+ bok = true;
+ for (var f in flds){
+ if ((f != "staffcontract_enddate") && ( f != "ident_staffcontract_id")){
+ if (flds[f] == ""){
+ bok=false;
+ }
+ }
+ //console.log(f + " => " + flds[f]);
+ }
+ if (bok == false){
+ document.getElementById("contractmsg").innerHTML= '<div class="w3-panel w3-red">Tous les champs sauf "date fin" sans requis!</div>';
+ return false;
+ }
flds["fn"] ="saveform";
flds["schemata"]=schemata;
flds["id_staff"]=staff.current_id;
flds["ident"] ="id";
- flds["ident_staffcontract_id"] = flds["ident_staffcontract_id_staffcontract"];
- delete flds["ident_staffcontract_id_staffcontract"];
- console.log(flds);
- delete flds["null"];
- req.reqdata("POST","index.cgi",flds,staffcontract.afterstaffcontractsaved);
+ // flds["ident_staffcontract_id"] = flds["ident_staffcontract_id_staffcontract"];
+
+ // delete flds["ident_staffcontract_id_staffcontract"];
+ // console.log(flds);
+ // delete flds["null"];
+
+
+ req.reqdata("POST","index.cgi",flds,staffcontract.afterstaffcontractsaved);
return false;
- //'staffcontract',staffcontract.afterstaffcontractsaved
+
},
afterstaffcontractsaved: function(){
staffcontract.gettbldata();
fillstaffgroups: function(data){
fillselectlist(staffcontract.choices["id_staffgroup"],data.sqldata,'id','groupname');
},
+ getwptemplates: function(){
+ req.reqdata("POST","db.cgi",{"get":"workplanlist","schemata":schemata},staffcontract.fillwptemplates);
+ },
+ fillwptemplates: function(data){
+ fillselectlist(staffcontract.choices["id_workplan"],data.sqldata,'id','workplan');
+ },
}
\ No newline at end of file
{title:"Position",field:"job"},
{title:"Téléphone",field:"phone"},
{title:"E-mail",field:"username"},
- {title:"Bloqué", field:"blocked"},
+ {title:"Bloqué", field:"blocked",formatter:"tickCross",align:"center",
+ formatterParams:{allowEmpty:true,allowTruthy:true,tickElement:'<span style="color: green;">✔</span>'}},
],
});
users.gettbldata();
--- /dev/null
+CREATE OR REPLACE VIEW portanova.vw_staffworkplan_weekly
+AS SELECT stw2.calweek,
+ to_char(stw2.caldate::timestamp with time zone, 'YYYY'::text) AS calyear,
+ stw2.caldate AS weekbegin,
+ getdateslist(stw2.caldate, 7) AS dates,
+ stw2.id_staff,
+ max(
+ CASE
+ WHEN stw2.isodow = 1::double precision THEN stw2.id
+ ELSE NULL::bigint
+ END) AS mon_id,
+ max(
+ CASE
+ WHEN stw2.isodow = 1::double precision THEN to_char(stw2.timestart1::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS mon_timestart1,
+ max(
+ CASE
+ WHEN stw2.isodow = 1::double precision THEN to_char(stw2.timeend1::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS mon_timeend1,
+ max(
+ CASE
+ WHEN stw2.isodow = 1::double precision THEN to_char(stw2.timestart2::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS mon_timestart2,
+ max(
+ CASE
+ WHEN stw2.isodow = 1::double precision THEN to_char(stw2.timeend2::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS mon_timeend2,
+ max(
+ CASE
+ WHEN stw2.isodow = 1::double precision THEN to_char(stw2.timepause::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS mon_timepause,
+ max(
+ CASE
+ WHEN stw2.isodow = 1::double precision THEN to_char(stw2.vacancyhours::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS mon_vacancyhours,
+ max(
+ CASE
+ WHEN stw2.isodow = 1::double precision THEN stw2.vacancyname
+ ELSE NULL::text
+ END) AS mon_vacancyname,
+ max(
+ CASE
+ WHEN stw2.isodow = 1::double precision THEN stw2.color
+ ELSE NULL::text
+ END) AS mon_color,
+ max(
+ CASE
+ WHEN stw2.isodow = 1::double precision THEN stw2.id_vacancytype
+ ELSE NULL::integer
+ END) AS mon_vacancytype,
+ max(
+ CASE
+ WHEN stw2.isodow = 1::double precision THEN stw2.daytype
+ ELSE NULL::integer
+ END) AS mon_daytype,
+ to_char(max(
+ CASE
+ WHEN stw2.isodow = 1::double precision THEN stw2.time1 + stw2.time2 - stw2.timepause::interval
+ ELSE NULL::interval
+ END), 'HH24:MI'::text) AS mon_timetotal,
+ max(
+ CASE
+ WHEN stw2.isodow = 2::double precision THEN stw2.id
+ ELSE NULL::bigint
+ END) AS tue_id,
+ max(
+ CASE
+ WHEN stw2.isodow = 2::double precision THEN to_char(stw2.timestart1::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS tue_timestart1,
+ max(
+ CASE
+ WHEN stw2.isodow = 2::double precision THEN to_char(stw2.timeend1::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS tue_timeend1,
+ max(
+ CASE
+ WHEN stw2.isodow = 2::double precision THEN to_char(stw2.timestart2::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS tue_timestart2,
+ max(
+ CASE
+ WHEN stw2.isodow = 2::double precision THEN to_char(stw2.timeend2::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS tue_timeend2,
+ max(
+ CASE
+ WHEN stw2.isodow = 2::double precision THEN to_char(stw2.timepause::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS tue_timepause,
+ max(
+ CASE
+ WHEN stw2.isodow = 2::double precision THEN to_char(stw2.vacancyhours::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS tue_vacancyhours,
+ max(
+ CASE
+ WHEN stw2.isodow = 2::double precision THEN stw2.id_vacancytype
+ ELSE NULL::integer
+ END) AS tue_vacancytype,
+ max(
+ CASE
+ WHEN stw2.isodow = 2::double precision THEN stw2.vacancyname
+ ELSE NULL::text
+ END) AS tue_vacancyname,
+ max(
+ CASE
+ WHEN stw2.isodow = 2::double precision THEN stw2.color
+ ELSE NULL::text
+ END) AS tue_color,
+ max(
+ CASE
+ WHEN stw2.isodow = 2::double precision THEN stw2.daytype
+ ELSE NULL::integer
+ END) AS tue_daytype,
+ to_char(max(
+ CASE
+ WHEN stw2.isodow = 2::double precision THEN stw2.time1 + stw2.time2 - stw2.timepause::interval
+ ELSE NULL::interval
+ END), 'HH24:MI'::text) AS tue_timetotal,
+ max(
+ CASE
+ WHEN stw2.isodow = 3::double precision THEN stw2.id
+ ELSE NULL::bigint
+ END) AS wed_id,
+ max(
+ CASE
+ WHEN stw2.isodow = 3::double precision THEN to_char(stw2.timestart1::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS wed_timestart1,
+ max(
+ CASE
+ WHEN stw2.isodow = 3::double precision THEN to_char(stw2.timeend1::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS wed_timeend1,
+ max(
+ CASE
+ WHEN stw2.isodow = 3::double precision THEN to_char(stw2.timestart2::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS wed_timestart2,
+ max(
+ CASE
+ WHEN stw2.isodow = 3::double precision THEN to_char(stw2.timeend2::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS wed_timeend2,
+ max(
+ CASE
+ WHEN stw2.isodow = 3::double precision THEN to_char(stw2.timepause::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS wed_timepause,
+ max(
+ CASE
+ WHEN stw2.isodow = 3::double precision THEN to_char(stw2.vacancyhours::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS wed_vacancyhours,
+ max(
+ CASE
+ WHEN stw2.isodow = 3::double precision THEN stw2.id_vacancytype
+ ELSE NULL::integer
+ END) AS wed_vacancytype,
+ max(
+ CASE
+ WHEN stw2.isodow = 3::double precision THEN stw2.vacancyname
+ ELSE NULL::text
+ END) AS wed_vacancyname,
+ max(
+ CASE
+ WHEN stw2.isodow = 3::double precision THEN stw2.color
+ ELSE NULL::text
+ END) AS wed_color,
+ max(
+ CASE
+ WHEN stw2.isodow = 3::double precision THEN stw2.daytype
+ ELSE NULL::integer
+ END) AS wed_daytype,
+ to_char(max(
+ CASE
+ WHEN stw2.isodow = 3::double precision THEN stw2.time1 + stw2.time2 - stw2.timepause::interval
+ ELSE NULL::interval
+ END), 'HH24:MI'::text) AS wed_timetotal,
+ max(
+ CASE
+ WHEN stw2.isodow = 4::double precision THEN stw2.id
+ ELSE NULL::bigint
+ END) AS thu_id,
+ max(
+ CASE
+ WHEN stw2.isodow = 4::double precision THEN to_char(stw2.timestart1::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS thu_timestart1,
+ max(
+ CASE
+ WHEN stw2.isodow = 4::double precision THEN to_char(stw2.timeend1::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS thu_timeend1,
+ max(
+ CASE
+ WHEN stw2.isodow = 4::double precision THEN to_char(stw2.timestart2::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS thu_timestart2,
+ max(
+ CASE
+ WHEN stw2.isodow = 4::double precision THEN to_char(stw2.timeend2::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS thu_timeend2,
+ max(
+ CASE
+ WHEN stw2.isodow = 4::double precision THEN to_char(stw2.timepause::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS thu_timepause,
+ max(
+ CASE
+ WHEN stw2.isodow = 4::double precision THEN to_char(stw2.vacancyhours::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS thu_vacancyhours,
+ max(
+ CASE
+ WHEN stw2.isodow = 4::double precision THEN stw2.id_vacancytype
+ ELSE NULL::integer
+ END) AS thu_vacancytype,
+ max(
+ CASE
+ WHEN stw2.isodow = 4::double precision THEN stw2.vacancyname
+ ELSE NULL::text
+ END) AS thu_vacancyname,
+ max(
+ CASE
+ WHEN stw2.isodow = 4::double precision THEN stw2.color
+ ELSE NULL::text
+ END) AS thu_color,
+ max(
+ CASE
+ WHEN stw2.isodow = 4::double precision THEN stw2.daytype
+ ELSE NULL::integer
+ END) AS thu_daytype,
+ to_char(max(
+ CASE
+ WHEN stw2.isodow = 4::double precision THEN stw2.time1 + stw2.time2 - stw2.timepause::interval
+ ELSE NULL::interval
+ END), 'HH24:MI'::text) AS thu_timetotal,
+ max(
+ CASE
+ WHEN stw2.isodow = 5::double precision THEN stw2.id
+ ELSE NULL::bigint
+ END) AS fri_id,
+ max(
+ CASE
+ WHEN stw2.isodow = 5::double precision THEN to_char(stw2.timestart1::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS fri_timestart1,
+ max(
+ CASE
+ WHEN stw2.isodow = 5::double precision THEN to_char(stw2.timeend1::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS fri_timeend1,
+ max(
+ CASE
+ WHEN stw2.isodow = 5::double precision THEN to_char(stw2.timestart2::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS fri_timestart2,
+ max(
+ CASE
+ WHEN stw2.isodow = 5::double precision THEN to_char(stw2.timeend2::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS fri_timeend2,
+ max(
+ CASE
+ WHEN stw2.isodow = 5::double precision THEN to_char(stw2.timepause::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS fri_timepause,
+ max(
+ CASE
+ WHEN stw2.isodow = 5::double precision THEN to_char(stw2.vacancyhours::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS fri_vacancyhours,
+ max(
+ CASE
+ WHEN stw2.isodow = 5::double precision THEN stw2.id_vacancytype
+ ELSE NULL::integer
+ END) AS fri_vacancytype,
+ max(
+ CASE
+ WHEN stw2.isodow = 5::double precision THEN stw2.vacancyname
+ ELSE NULL::text
+ END) AS fri_vacancyname,
+ max(
+ CASE
+ WHEN stw2.isodow = 5::double precision THEN stw2.color
+ ELSE NULL::text
+ END) AS fri_color,
+ max(
+ CASE
+ WHEN stw2.isodow = 5::double precision THEN stw2.daytype
+ ELSE NULL::integer
+ END) AS fri_daytype,
+ to_char(max(
+ CASE
+ WHEN stw2.isodow = 5::double precision THEN stw2.time1 + stw2.time2 - stw2.timepause::interval
+ ELSE NULL::interval
+ END), 'HH24:MI'::text) AS fri_timetotal,
+ max(
+ CASE
+ WHEN stw2.isodow = 6::double precision THEN stw2.id
+ ELSE NULL::bigint
+ END) AS sat_id,
+ max(
+ CASE
+ WHEN stw2.isodow = 6::double precision THEN to_char(stw2.timestart1::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS sat_timestart1,
+ max(
+ CASE
+ WHEN stw2.isodow = 6::double precision THEN to_char(stw2.timeend1::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS sat_timeend1,
+ max(
+ CASE
+ WHEN stw2.isodow = 6::double precision THEN to_char(stw2.timestart2::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS sat_timestart2,
+ max(
+ CASE
+ WHEN stw2.isodow = 6::double precision THEN to_char(stw2.timeend2::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS sat_timeend2,
+ max(
+ CASE
+ WHEN stw2.isodow = 6::double precision THEN to_char(stw2.timepause::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS sat_timepause,
+ max(
+ CASE
+ WHEN stw2.isodow = 6::double precision THEN to_char(stw2.vacancyhours::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS sat_vacancyhours,
+ max(
+ CASE
+ WHEN stw2.isodow = 6::double precision THEN stw2.id_vacancytype
+ ELSE NULL::integer
+ END) AS sat_vacancytype,
+ max(
+ CASE
+ WHEN stw2.isodow = 6::double precision THEN stw2.vacancyname
+ ELSE NULL::text
+ END) AS sat_vacancyname,
+ max(
+ CASE
+ WHEN stw2.isodow = 6::double precision THEN stw2.color
+ ELSE NULL::text
+ END) AS sat_color,
+ max(
+ CASE
+ WHEN stw2.isodow = 6::double precision THEN stw2.daytype
+ ELSE NULL::integer
+ END) AS sat_daytype,
+ to_char(max(
+ CASE
+ WHEN stw2.isodow = 6::double precision THEN stw2.time1 + stw2.time2 - stw2.timepause::interval
+ ELSE NULL::interval
+ END), 'HH24:MI'::text) AS sat_timetotal,
+ max(
+ CASE
+ WHEN stw2.isodow = 7::double precision THEN stw2.id
+ ELSE NULL::bigint
+ END) AS sun_id,
+ max(
+ CASE
+ WHEN stw2.isodow = 7::double precision THEN to_char(stw2.timestart1::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS sun_timestart1,
+ max(
+ CASE
+ WHEN stw2.isodow = 7::double precision THEN to_char(stw2.timeend1::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS sun_timeend1,
+ max(
+ CASE
+ WHEN stw2.isodow = 7::double precision THEN to_char(stw2.timestart2::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS sun_timestart2,
+ max(
+ CASE
+ WHEN stw2.isodow = 7::double precision THEN to_char(stw2.timeend2::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS sun_timeend2,
+ max(
+ CASE
+ WHEN stw2.isodow = 7::double precision THEN to_char(stw2.timepause::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS sun_timepause,
+ max(
+ CASE
+ WHEN stw2.isodow = 7::double precision THEN to_char(stw2.vacancyhours::interval, 'HH24:MI'::text)
+ ELSE NULL::text
+ END) AS sun_vacancyhours,
+ max(
+ CASE
+ WHEN stw2.isodow = 7::double precision THEN stw2.id_vacancytype
+ ELSE NULL::integer
+ END) AS sun_vacancytype,
+ max(
+ CASE
+ WHEN stw2.isodow = 7::double precision THEN stw2.vacancyname
+ ELSE NULL::text
+ END) AS sun_vacancyname,
+ max(
+ CASE
+ WHEN stw2.isodow = 7::double precision THEN stw2.color
+ ELSE NULL::text
+ END) AS sun_color,
+ max(
+ CASE
+ WHEN stw2.isodow = 7::double precision THEN stw2.daytype
+ ELSE NULL::integer
+ END) AS sun_daytype,
+ to_char(max(
+ CASE
+ WHEN stw2.isodow = 7::double precision THEN stw2.time1 + stw2.time2 - stw2.timepause::interval
+ ELSE NULL::interval
+ END), 'HH24:MI'::text) AS sun_timetotal,
+ to_char(sum(stw2.time1 + stw2.time2 - stw2.timepause::interval), 'HH24:MI'::text) AS week_timetotal,
+ CASE
+ WHEN stw2.calweek IS NOT NULL AND stw2.id_staff IS NOT NULL THEN weekvacancy('portanova'::text, stw2.calweek, stw2.id_staff)
+ ELSE NULL::text
+ END AS week_vacancy,
+ stw2.staffname AS dspstaffname
+ FROM ( SELECT stw.daydate,
+ date_part('week'::text, stw.daydate) AS calweek,
+ date_trunc('week'::text, stw.daydate::timestamp with time zone)::date AS caldate,
+ date_part('isodow'::text, stw.daydate) AS isodow,
+ stw.id,
+ stw.id_staff,
+ (st.surname || ' '::text) || st.prename AS staffname,
+ stw.timestart1,
+ stw.timeend1,
+ stw.vacancyhours,
+ stw.id_vacancytype,
+ vt.color,
+ vt.vacancyname,
+ stw.daytype,
+ CASE
+ WHEN stw.timestart1 > stw.timeend1 THEN '24:00:00'::time without time zone - (stw.timestart1 - stw.timeend1)::time without time zone
+ ELSE stw.timeend1 - stw.timestart1
+ END AS time1,
+ stw.timestart2,
+ stw.timeend2,
+ CASE
+ WHEN stw.timestart2 > stw.timeend2 THEN '24:00:00'::time without time zone - (stw.timestart2 - stw.timeend2)::time without time zone
+ ELSE stw.timeend2 - stw.timestart2
+ END AS time2,
+ stw.timepause
+ FROM portanova.staffworkplan stw
+ LEFT JOIN portanova.staff st ON stw.id_staff = st.id
+ LEFT JOIN portanova.vacancytypes vt ON stw.id_vacancytype = vt.id) stw2
+ GROUP BY stw2.calweek, stw2.caldate, stw2.id_staff, stw2.staffname;
+
+
+
+
+CREATE OR REPLACE VIEW portanova.vw_staffworkplanlist
+AS SELECT st.id AS id_staff,
+ (st.surname || ' '::text) || st.prename AS staffname,
+ ((((('Semaine '::text || sp_dwt.calweek) || '<br/><span style="font-size: 8pt;">'::text) || to_char(sp_dwt.weekbegin::timestamp with time zone, 'DD.MM.YYYY'::text)) || '<br/>'::text) || to_char(date(sp_dwt.weekbegin + '7 days'::interval)::timestamp with time zone, 'DD.MM.YYYY'::text)) || '</span>'::text AS dspcalweek,
+ sp_dwt.calweek::integer AS calweek,
+ sp_dwt.calyear,
+ sp_dwt.week_timetotal,
+ sp_dwt.weekbegin AS weekstart,
+ sp_dwt.week_vacancy,
+ date(sp_dwt.weekbegin + '6 days'::interval) AS weekend,
+ to_number("left"(sp_dwt.week_timetotal, 2), '99'::text) * 60::numeric + to_number("right"(sp_dwt.week_timetotal, 2), '99'::text) AS weekminutes,
+ sp_dwt.mon_id,
+ sp_dwt.weekbegin AS mon_date,
+ (COALESCE((to_char(sp_dwt.mon_timestart1::interval, 'HH24:MI'::text) || ' - '::text) || to_char(sp_dwt.mon_timeend1::interval, 'HH24:MI'::text), ''::text) || COALESCE((('<br/>'::text || to_char(sp_dwt.mon_timestart2::interval, 'HH24:MI'::text)) || ' - '::text) || to_char(sp_dwt.mon_timeend2::interval, 'HH24:MI'::text), ''::text)) || COALESCE(('<br/>('::text || to_char(sp_dwt.mon_timepause::interval, 'HH24:MI'::text)) || ')'::text, ''::text) AS dspmontimes,
+ COALESCE(((((('<span style="color:'::text || sp_dwt.mon_color) || ';">'::text) || to_char(sp_dwt.mon_vacancyhours::interval, 'HH24:MI'::text)) || '<br/>('::text) || sp_dwt.mon_vacancyname) || ')</span>'::text, ''::text) AS dspmonvacancy,
+ sp_dwt.mon_timetotal,
+ sp_dwt.mon_vacancyhours,
+ sp_dwt.mon_vacancytype,
+ sp_dwt.tue_id,
+ date(sp_dwt.weekbegin + '1 day'::interval) AS tue_date,
+ (COALESCE((to_char(sp_dwt.tue_timestart1::interval, 'HH24:MI'::text) || ' - '::text) || to_char(sp_dwt.tue_timeend1::interval, 'HH24:MI'::text), ''::text) || COALESCE((('<br/>'::text || to_char(sp_dwt.tue_timestart2::interval, 'HH24:MI'::text)) || ' - '::text) || to_char(sp_dwt.tue_timeend2::interval, 'HH24:MI'::text), ''::text)) || COALESCE(('<br/>('::text || to_char(sp_dwt.tue_timepause::interval, 'HH24:MI'::text)) || ')'::text, ''::text) AS dsptuetimes,
+ COALESCE(((((('<span style="color:'::text || sp_dwt.tue_color) || ';">'::text) || to_char(sp_dwt.tue_vacancyhours::interval, 'HH24:MI'::text)) || '<br/>('::text) || sp_dwt.tue_vacancyname) || ')</span>'::text, ''::text) AS dsptuevacancy,
+ sp_dwt.tue_timetotal,
+ sp_dwt.tue_vacancyhours,
+ sp_dwt.tue_vacancytype,
+ sp_dwt.wed_id,
+ date(sp_dwt.weekbegin + '2 days'::interval) AS wed_date,
+ (COALESCE((to_char(sp_dwt.wed_timestart1::interval, 'HH24:MI'::text) || ' - '::text) || to_char(sp_dwt.wed_timeend1::interval, 'HH24:MI'::text), ''::text) || COALESCE((('<br/>'::text || to_char(sp_dwt.wed_timestart2::interval, 'HH24:MI'::text)) || ' - '::text) || to_char(sp_dwt.wed_timeend2::interval, 'HH24:MI'::text), ''::text)) || COALESCE(('<br/>('::text || to_char(sp_dwt.wed_timepause::interval, 'HH24:MI'::text)) || ')'::text, ''::text) AS dspwedtimes,
+ COALESCE(((((('<span style="color:'::text || sp_dwt.wed_color) || ';">'::text) || to_char(sp_dwt.wed_vacancyhours::interval, 'HH24:MI'::text)) || '<br/>('::text) || sp_dwt.wed_vacancyname) || ')</span>'::text, ''::text) AS dspwedvacancy,
+ sp_dwt.wed_timetotal,
+ sp_dwt.wed_vacancyhours,
+ sp_dwt.wed_vacancytype,
+ sp_dwt.thu_id,
+ date(sp_dwt.weekbegin + '3 days'::interval) AS thu_date,
+ (COALESCE((to_char(sp_dwt.thu_timestart1::interval, 'HH24:MI'::text) || ' - '::text) || to_char(sp_dwt.thu_timeend1::interval, 'HH24:MI'::text), ''::text) || COALESCE((('<br/>'::text || to_char(sp_dwt.thu_timestart2::interval, 'HH24:MI'::text)) || ' - '::text) || to_char(sp_dwt.thu_timeend2::interval, 'HH24:MI'::text), ''::text)) || COALESCE(('<br/>('::text || to_char(sp_dwt.thu_timepause::interval, 'HH24:MI'::text)) || ')'::text, ''::text) AS dspthutimes,
+ COALESCE(((((('<span style="color:'::text || sp_dwt.thu_color) || ';">'::text) || to_char(sp_dwt.thu_vacancyhours::interval, 'HH24:MI'::text)) || '<br/>('::text) || sp_dwt.thu_vacancyname) || ')</span>'::text, ''::text) AS dspthuvacancy,
+ sp_dwt.thu_timetotal,
+ sp_dwt.thu_vacancyhours,
+ sp_dwt.thu_vacancytype,
+ sp_dwt.fri_id,
+ date(sp_dwt.weekbegin + '4 days'::interval) AS fri_date,
+ (COALESCE((to_char(sp_dwt.fri_timestart1::interval, 'HH24:MI'::text) || ' -'::text) || to_char(sp_dwt.fri_timeend1::interval, 'HH24:MI'::text), ''::text) || COALESCE((('<br/>'::text || to_char(sp_dwt.fri_timestart2::interval, 'HH24:MI'::text)) || ' - '::text) || to_char(sp_dwt.fri_timeend2::interval, 'HH24:MI'::text), ''::text)) || COALESCE(('<br/>('::text || to_char(sp_dwt.fri_timepause::interval, 'HH24:MI'::text)) || ')'::text, ''::text) AS dspfritimes,
+ COALESCE(((((('<span style="color:'::text || sp_dwt.fri_color) || ';">'::text) || to_char(sp_dwt.fri_vacancyhours::interval, 'HH24:MI'::text)) || '<br/>('::text) || sp_dwt.fri_vacancyname) || ')</span>'::text, ''::text) AS dspfrivacancy,
+ sp_dwt.fri_timetotal,
+ sp_dwt.fri_vacancyhours,
+ sp_dwt.fri_vacancytype,
+ sp_dwt.sat_id,
+ date(sp_dwt.weekbegin + '5 days'::interval) AS sat_date,
+ (COALESCE((to_char(sp_dwt.sat_timestart1::interval, 'HH24:MI'::text) || ' - '::text) || to_char(sp_dwt.sat_timeend1::interval, 'HH24:MI'::text), ''::text) || COALESCE((('<br/>'::text || to_char(sp_dwt.sat_timestart2::interval, 'HH24:MI'::text)) || ' - '::text) || to_char(sp_dwt.sat_timeend2::interval, 'HH24:MI'::text), ''::text)) || COALESCE(('<br/>('::text || to_char(sp_dwt.sat_timepause::interval, 'HH24:MI'::text)) || ')'::text, ''::text) AS dspsattimes,
+ COALESCE(((((('<span style="color:'::text || sp_dwt.sat_color) || ';">'::text) || to_char(sp_dwt.sat_vacancyhours::interval, 'HH24:MI'::text)) || '<br/>('::text) || sp_dwt.sat_vacancyname) || ')</span>'::text, ''::text) AS dspsatvacancy,
+ sp_dwt.sat_timetotal,
+ sp_dwt.sat_vacancyhours,
+ sp_dwt.sat_vacancytype,
+ sp_dwt.sun_id,
+ date(sp_dwt.weekbegin + '6 days'::interval) AS sun_date,
+ (COALESCE((to_char(sp_dwt.sun_timestart1::interval, 'HH24:MI'::text) || ' - '::text) || to_char(sp_dwt.sun_timeend1::interval, 'HH24:MI'::text), ''::text) || COALESCE((('<br/>'::text || to_char(sp_dwt.sun_timestart2::interval, 'HH24:MI'::text)) || ' - '::text) || to_char(sp_dwt.sun_timeend2::interval, 'HH24:MI'::text), ''::text)) || COALESCE(('<br/>('::text || to_char(sp_dwt.sun_timepause::interval, 'HH24:MI'::text)) || ')'::text, ''::text) AS dspsuntimes,
+ COALESCE(((((('<span style="color:'::text || sp_dwt.sun_color) || 'M">'::text) || to_char(sp_dwt.sun_vacancyhours::interval, 'HH24:MI'::text)) || '<br/>('::text) || sp_dwt.sun_vacancyname) || ')</span>'::text, ''::text) AS dspsunvacancy,
+ sp_dwt.sun_timetotal,
+ sp_dwt.sun_vacancyhours,
+ sp_dwt.sun_vacancytype
+ FROM portanova.vw_staffworkplan_weekly sp_dwt
+ LEFT JOIN portanova.staff st ON sp_dwt.id_staff = st.id
+ ORDER BY sp_dwt.calweek;
+