From e269da0fc4aa4b89dd5043e276e00638b39ca0d7 Mon Sep 17 00:00:00 2001 From: Kilian Saffran Date: Wed, 8 Jan 2020 18:09:28 +0100 Subject: [PATCH] v20200108 datefields staffcontract --- backoffice/css/w3pro.css | 12 +- backoffice/js/admin.js | 4 + backoffice/js/formsave.js | 33 +- backoffice/js/request.js | 2 +- backoffice/tmpl/block/toolbars.tt | 8 +- backoffice/tmpl/macro/fields.tt | 21 +- .../{widgets/companies => }/companies.js | 27 +- backoffice/tmpl/module/companies/index.js | 1 + backoffice/tmpl/module/companies/index.tt | 77 +- .../tmpl/module/companies/staffgroups.js | 73 ++ .../widgets/companies/frm_companies.tt | 35 - .../widgets/companies/tbar_companies.tt | 7 - .../widgets/companies/tbl_companies.tt | 3 - backoffice/tmpl/module/planning/index.tt | 109 ++- .../tmpl/module/planning/reportperiod.js | 4 +- .../tmpl/module/planning/staffworkplan.js | 200 ++++- backoffice/tmpl/module/sites/index.js | 3 +- backoffice/tmpl/module/staff/index.tt | 94 ++- .../module/staff/{widgets/staff => }/staff.js | 3 - .../staffcontract => }/staffcontract.js | 74 +- .../module/staff/widgets/staff/frm_staff.tt | 34 - .../module/staff/widgets/staff/tbar_staff.tt | 7 - .../module/staff/widgets/staff/tbl_staff.tt | 3 - .../staffcontract/dlg_staffcontract.tt | 24 - .../staffcontract/tbar_staffcontract.tt | 8 - .../staffcontract/tbl_staffcontract.tt | 7 - backoffice/tmpl/module/timetrackers/index.tt | 12 +- backoffice/tmpl/module/users/index.tt | 47 +- .../module/users/{widgets/users => }/users.js | 27 +- .../module/users/widgets/users/dlg_users.tt | 30 - .../module/users/widgets/users/tbar_users.tt | 5 - .../module/users/widgets/users/tbl_users.tt | 3 - backoffice/tmpl/module/workplans/index.tt | 12 +- backoffice/tmpl/skeleton/module.tt | 8 +- backoffice/vendors/choices/base.css | 4 +- backoffice/vendors/choices/base.min.css | 3 +- backoffice/vendors/flatpickr/flatpickr.js | 50 +- backoffice/vendors/flatpickr/flatpickr.min.js | 2 +- .../flatpickr/plugins/minMaxTimePlugin.js | 2 +- .../vendors/flatpickr/themes/confetti.css | 795 ----------------- backoffice/vendors/flatpickr/themes/dark.css | 784 ----------------- backoffice/vendors/flatpickr/themes/light.css | 798 ------------------ .../flatpickr/themes/material_blue.css | 795 ----------------- .../flatpickr/themes/material_green.css | 795 ----------------- .../flatpickr/themes/material_orange.css | 795 ----------------- .../vendors/flatpickr/themes/material_red.css | 795 ----------------- tmpl/skeleton/index.tt | 2 +- 47 files changed, 741 insertions(+), 5896 deletions(-) rename backoffice/tmpl/module/companies/{widgets/companies => }/companies.js (80%) create mode 100644 backoffice/tmpl/module/companies/staffgroups.js delete mode 100644 backoffice/tmpl/module/companies/widgets/companies/frm_companies.tt delete mode 100644 backoffice/tmpl/module/companies/widgets/companies/tbar_companies.tt delete mode 100644 backoffice/tmpl/module/companies/widgets/companies/tbl_companies.tt rename backoffice/tmpl/module/staff/{widgets/staff => }/staff.js (98%) rename backoffice/tmpl/module/staff/{widgets/staffcontract => }/staffcontract.js (65%) delete mode 100644 backoffice/tmpl/module/staff/widgets/staff/frm_staff.tt delete mode 100644 backoffice/tmpl/module/staff/widgets/staff/tbar_staff.tt delete mode 100644 backoffice/tmpl/module/staff/widgets/staff/tbl_staff.tt delete mode 100644 backoffice/tmpl/module/staff/widgets/staffcontract/dlg_staffcontract.tt delete mode 100644 backoffice/tmpl/module/staff/widgets/staffcontract/tbar_staffcontract.tt delete mode 100644 backoffice/tmpl/module/staff/widgets/staffcontract/tbl_staffcontract.tt rename backoffice/tmpl/module/users/{widgets/users => }/users.js (83%) delete mode 100644 backoffice/tmpl/module/users/widgets/users/dlg_users.tt delete mode 100644 backoffice/tmpl/module/users/widgets/users/tbar_users.tt delete mode 100644 backoffice/tmpl/module/users/widgets/users/tbl_users.tt delete mode 100644 backoffice/vendors/flatpickr/themes/confetti.css delete mode 100644 backoffice/vendors/flatpickr/themes/dark.css delete mode 100644 backoffice/vendors/flatpickr/themes/light.css delete mode 100644 backoffice/vendors/flatpickr/themes/material_blue.css delete mode 100644 backoffice/vendors/flatpickr/themes/material_green.css delete mode 100644 backoffice/vendors/flatpickr/themes/material_orange.css delete mode 100644 backoffice/vendors/flatpickr/themes/material_red.css diff --git a/backoffice/css/w3pro.css b/backoffice/css/w3pro.css index 13ca6338..5519748a 100644 --- a/backoffice/css/w3pro.css +++ b/backoffice/css/w3pro.css @@ -45,8 +45,8 @@ hr{border:0;border-top:1px solid #eee;margin:20px 0} .w3-ul{list-style-type:none;padding:0;margin:0}.w3-ul li{padding:8px 16px;border-bottom:1px solid #ddd}.w3-ul li:last-child{border-bottom:none} .w3-tooltip,.w3-display-container{position:relative}.w3-tooltip .w3-text{display:none}.w3-tooltip:hover .w3-text{display:inline-block} .w3-ripple:active{opacity:0.5}.w3-ripple{transition:opacity 0s} -.w3-input{padding:4px;display:block;border:1px solid #ccc;width:100%;background-color: #e8f0fe;border-radius:4px; } -.w3-input-append{padding:4px;display:block;border:1px solid #ccc;float:left;background-color: #e8f0fe;border-radius-left:4px } +.w3-input{padding:4px;display:block;border:1px solid #ccc;width:100%;background-color: #e8f0fe; } +.w3-input-append{padding:4px;display:block;border:1px solid #ccc;float:left;background-color: #e8f0fe;} .w3-select{padding:4px 0; display:block;width:100%;border:1px solid #ccc;background-color: #e8f0fe;} .w3-dropdown-click,.w3-dropdown-hover{position:relative;display:inline-block;cursor:pointer} .w3-dropdown-hover:hover .w3-dropdown-content{display:block; } @@ -136,7 +136,7 @@ hr{border:0;border-top:1px solid #eee;margin:20px 0} .w3-border-left{border-left:1px solid #ccc!important}.w3-border-right{border-right:1px solid #ccc!important} .w3-topbar{border-top:6px solid #ccc!important}.w3-bottombar{border-bottom:6px solid #ccc!important} .w3-leftbar{border-left:6px solid #ccc!important}.w3-rightbar{border-right:6px solid #ccc!important} -.w3-section,.w3-code{margin-top:16px!important;margin-bottom:16px!important} +.w3-section,.w3-code{margin-top:2px!important;margin-bottom:16px!important} .w3-margin{margin:16px!important}.w3-margin-top{margin-top:16px!important}.w3-margin-bottom{margin-bottom:16px!important} .w3-margin-left{margin-left:16px!important}.w3-margin-right{margin-right:16px!important} .w3-padding-small{padding:4px 8px!important}.w3-padding{padding:8px 16px!important}.w3-padding-large{padding:12px 24px!important} @@ -281,7 +281,7 @@ hr{border:0;border-top:1px solid #eee;margin:20px 0} -webkit-appearance: none; appearance: none; background-color: #e8f0fe; - border-radius:4px; + /*border-radius:4px; */ background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23000%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E'), linear-gradient(to bottom, #e8f0fe 0%,#e8f0fe 100%); background-repeat: no-repeat, repeat; @@ -320,7 +320,7 @@ hr{border:0;border-top:1px solid #eee;margin:20px 0} background-color: #333; color: #fff; text-align: center; - border-radius: 2px; + /*border-radius: 2px; */ padding: 16px; position: fixed; z-index: 1; @@ -363,7 +363,7 @@ hr{border:0;border-top:1px solid #eee;margin:20px 0} .w3-readonly { pointer-events:none; - padding:8px;display:block;border:0px;width:100%;background-color: #fff; + display:block;border:0px;width:100%;background-color: #fff; } .right-side-bg { diff --git a/backoffice/js/admin.js b/backoffice/js/admin.js index f0c20a84..e944507e 100644 --- a/backoffice/js/admin.js +++ b/backoffice/js/admin.js @@ -108,4 +108,8 @@ function fillselectlist(obj,data,vidcol,vvalcol){ obj.setChoices(sellist, 'value', 'label', true); obj.setChoiceByValue(sellist[0].value); return false; +} + +function setschemata(schemaname){ + choice["company"]["schemata"].setChoiceByValue(schemaname); } \ No newline at end of file diff --git a/backoffice/js/formsave.js b/backoffice/js/formsave.js index 10c8952a..32c1f508 100644 --- a/backoffice/js/formsave.js +++ b/backoffice/js/formsave.js @@ -2,7 +2,7 @@ function saveform(frmid,aftercallback){ var flds=getformcontent(frmid,null); flds["fn"] ="saveform"; flds["schemata"]=schemata; - console.log(flds); + //console.log(flds); delete flds["null"]; if (aftercallback){ req.reqdata("POST","index.cgi",flds,aftercallback); @@ -40,7 +40,7 @@ function getformcontent(frmid,dataflds){ for (var i = 0; i < frm.elements.length; i++) { var field = frm.elements[i]; //console.log("field:" + field.id + " Name:" + field.getAttribute("name")); - if (field.tagName == "INPUT" || field.tagName == "SELECT" || field.tagName == "TEXTAREA"){ + if ((field.getAttribute("name") != 'null') && (field.tagName == "INPUT" || field.tagName == "SELECT" || field.tagName == "TEXTAREA")){ if (field.classList.contains("tagedit")){ var fvalue=field.value.trim(); var ndata = null; @@ -64,8 +64,7 @@ function getformcontent(frmid,dataflds){ } } - else { - if (field.tagName == "SELECT" && field.multiple == true){ + else if (field.tagName == "SELECT" && field.multiple == true){ var opts = field.selectedOptions; var vals = []; for (var o in opts){ @@ -77,18 +76,19 @@ function getformcontent(frmid,dataflds){ flds[field.getAttribute("name")] = vals; } else { flds[field.getAttribute("name")] = ""; - } - - } else { - flds[field.getAttribute("name")] = field.value; - } - + } + } + else { + console.log(field.classList); + console.log("field:" + field.id + " Name:" + field.getAttribute("name")); + console.log("val:" + field.value); + flds[field.getAttribute("name")] = field.value; } } } - console.log("Fields to Save"); - console.log(flds); + //console.log("Fields to Save"); + //console.log(flds); return flds; } @@ -212,10 +212,12 @@ function fillformbydataclass(dataclass,data,readonly = false){ } if (frm[f].tagName == 'SELECT'){ if (frm[f].classList.contains("choices__input")){ + console.log(frm[f].id); if (frm[f].multiple == true){ //console.log(data[frm[f].id]); choice[dataclass][frm[f].id].setChoiceByValue(JSON.parse(data[frm[f].id])); }else { + console.log(frm[f].id); choice[dataclass][frm[f].id].setChoiceByValue(data[frm[f].id]); } } else { @@ -230,13 +232,14 @@ function fillformbydataclass(dataclass,data,readonly = false){ } function fillformbydataclass2(dataclass,choices,data){ - console.log(data); + //console.log(data); + console.log("fill data class: " + dataclass); var frm = document.querySelectorAll('.data_'+ dataclass); if (data){ for (var f in frm){ //console.log(frm[f]); if (data[frm[f].id]){ - console.log(frm[f].id + " => " + data[frm[f].id]); + //console.log(frm[f].id + " => " + data[frm[f].id]); if (frm[f].tagName == 'INPUT'){ if (frm[f].type == "checkbox"){ @@ -251,6 +254,7 @@ function fillformbydataclass2(dataclass,choices,data){ frm[f]._flatpickr.setDate(data[frm[f].id]); }else if (frm[f].classList.contains("choices__input")){ if ((data[frm[f].id] != null) && (data[frm[f].id] != '[""]')){ + console.log(frm[f].id); choices[frm[f].id].setValue(JSON.parse(data[frm[f].id])); } } else { @@ -263,6 +267,7 @@ function fillformbydataclass2(dataclass,choices,data){ console.log("is multiple: " + data[frm[f].id]); choices[frm[f].id].setChoiceByValue(JSON.parse(data[frm[f].id])); }else { + console.log("is single: " + frm[f].id + " " + data[frm[f].id]); choices[frm[f].id].setChoiceByValue(data[frm[f].id]); } } else { diff --git a/backoffice/js/request.js b/backoffice/js/request.js index 4e80e025..19f2a332 100644 --- a/backoffice/js/request.js +++ b/backoffice/js/request.js @@ -82,7 +82,7 @@ var req = { //console.log("Status returned: " + request.status + "resp:" + request.getResponseHeader("Content-Type")); if (request.getResponseHeader("Content-Type").indexOf('application/json') == 0){ if (request.responseText){ - console.log(request.responseText); + //console.log(request.responseText); var xparse = JSON.parse(request.responseText); ret = xparse.result; } else { diff --git a/backoffice/tmpl/block/toolbars.tt b/backoffice/tmpl/block/toolbars.tt index 34a14783..5672a5ce 100644 --- a/backoffice/tmpl/block/toolbars.tt +++ b/backoffice/tmpl/block/toolbars.tt @@ -1,9 +1,9 @@ [% MACRO tabletoolbar(ident) BLOCK -%]
- - - - + + + +
[% END -%] \ No newline at end of file diff --git a/backoffice/tmpl/macro/fields.tt b/backoffice/tmpl/macro/fields.tt index a2acb3af..384031c9 100644 --- a/backoffice/tmpl/macro/fields.tt +++ b/backoffice/tmpl/macro/fields.tt @@ -77,17 +77,34 @@ [% END -%] -[% MACRO fielddatebox(column,table,title,size,state,value) BLOCK -%] +[% MACRO fieldmultidatebox(column,table,title,size,state,value) BLOCK -%]
0 %][% state %][% END %]]/>
[% END -%] +[% MACRO fielddatebox(column,table,title,size,state,value) BLOCK -%] +
+ +
+ [% IF state == "disabled" || state == "readonly" %] + + [% ELSE %] +
+ +
+
+ +
+ [% END %] +
+
+[% END -%] [% MACRO fieldtimebox(column,table,title,size,state,value) BLOCK -%]
-
+
[% IF state == "disabled" || state == "readonly" %] [% ELSE %] diff --git a/backoffice/tmpl/module/companies/widgets/companies/companies.js b/backoffice/tmpl/module/companies/companies.js similarity index 80% rename from backoffice/tmpl/module/companies/widgets/companies/companies.js rename to backoffice/tmpl/module/companies/companies.js index 72ac9b64..ce6ac4e9 100644 --- a/backoffice/tmpl/module/companies/widgets/companies/companies.js +++ b/backoffice/tmpl/module/companies/companies.js @@ -1,5 +1,6 @@ //var tbl_companies = null; //var weekdays= ["mon","tue","wed","thu","fri","sat","sun"]; + var companies ={ tbl: null, current_company: null, @@ -40,12 +41,21 @@ var companies ={ title: "pays", field: "country", headerFilter: "input" + },{ + title: "Schemata", + field: "schemata", + }] }); companies.gettbldata(); }, gettbldata: function(){ - req.reqdata("POST", "db.cgi", { "get": companies.name + "list","schemata":schemata}, companies.loadtbldata); + //console.log("isadmin [% session.usergroups.search('admin') %]"); + [% IF session.usergroups.search('admin') != 1 %] + 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); + [% END %] }, loadtbldata: function(data){ if (data && data.sqldata) { companies.tbl.setData(data.sqldata);} @@ -56,13 +66,17 @@ var companies ={ module.viewpanel('frm_' + companies.name); }, edit: function(){ - console.log("force remove event"); + //console.log("force remove event"); document.getElementById("company").removeEventListener('blur',function(){},true); var udata = companies.tbl.getSelectedData(); + if (udata[0]) { + parent.setschemata(udata[0].schemata); cleanform2(companies.name,companies.choices); req.reqdata("POST", "db.cgi", { "get": companies.name + "data","schemata":schemata, "filter":"id='" + udata[0].id + "'"}, companies.fillform); + staffgroups.gettbldata(); module.viewpanel('frm_' +companies.name); + } }, fillform: function(data){ @@ -81,6 +95,15 @@ var companies ={ } }, saveform: function(){ + var company = document.getElementById("company").value; + if (company == ''){ + showmessagedlg("Erreur",'
Le Champ "Entreprise" ne doit pas être vide!
'); + return false; + } + if (company.length < 3){ + showmessagedlg("Erreur",'
Le Champ "Entreprise" contenir au moins 3 lettres!'); + return false; + } //var wpdata = getformcontent(companies.name); //TODO: save form //console.log(wpdata); diff --git a/backoffice/tmpl/module/companies/index.js b/backoffice/tmpl/module/companies/index.js index 9a6202c3..2c607518 100644 --- a/backoffice/tmpl/module/companies/index.js +++ b/backoffice/tmpl/module/companies/index.js @@ -4,5 +4,6 @@ function initpage(){ //schemata = parent.admin.getcurrentSchemata(); console.log("Current Schema:" + schemata); companies.inittable(); + staffgroups.inittable(); module.viewpanel("tbl_companies"); } diff --git a/backoffice/tmpl/module/companies/index.tt b/backoffice/tmpl/module/companies/index.tt index 0c049241..44881adf 100644 --- a/backoffice/tmpl/module/companies/index.tt +++ b/backoffice/tmpl/module/companies/index.tt @@ -1,13 +1,80 @@ +[% PROCESS macro/fields.tt %]
- + - [% INCLUDE "module/$module/widgets/companies/tbar_companies.tt" %] + + +
+
+
+
+
+ +
+
+ +
+
+ × +

Département

+
+
+ [% fieldhidden("id","staffgroups",'ident','') %] + [% fieldeditbox("groupname","staffgroups","Nom du Département",'w3-third','','','') %]
+
+ + +
- [% INCLUDE "module/$module/widgets/companies/tbl_companies.tt" %] - [% INCLUDE "module/$module/widgets/companies/frm_companies.tt" %]
[% INCLUDE block/dlgdeleterow.tt %] - +[% INCLUDE block/dlgmessage.tt %] + + diff --git a/backoffice/tmpl/module/companies/staffgroups.js b/backoffice/tmpl/module/companies/staffgroups.js new file mode 100644 index 00000000..56127d85 --- /dev/null +++ b/backoffice/tmpl/module/companies/staffgroups.js @@ -0,0 +1,73 @@ +var staffgroups = { + tbl: null, + name: "staffgroups", + choices:{}, + initform: function(){ + + }, + inittable: function(){ + staffgroups.tbl = new Tabulator("#tbl_" + staffgroups.name, { + headerFilterPlaceholder: "filter...", + height: "94vh", + layout: "fitData", + selectable: 1, + rowContext:function(e, row){ + //e - the click event object + //row - row component + e.preventDefault(); // prevent the browsers default context menu form appearing. + }, + columns: [{ + title: "Département", + field: "groupname" + }] + }); + staffgroups.gettbldata(); + }, + gettbldata: function(){ + req.reqdata("POST", "db.cgi", { "get": staffgroups.name + "list","schemata":parent.admin.getcurrentSchemata()}, staffgroups.loadtbldata); + }, + loadtbldata: function(data){ + if (data && data.sqldata) { staffgroups.tbl.setData(data.sqldata);} + }, + add: function(){ + cleanform2(staffgroups.name,staffgroups.choices); + //document.getElementById("company").addEventListener('blur', function(event){companies.checkschema(event,this.id);},true); + module.viewdialog(staffgroups.name); + }, + edit: function(){ + var udata = staffgroups.tbl.getSelectedData(); + if (udata[0]) { + cleanform2(staffgroups.name,staffgroups.choices); + req.reqdata("POST", "db.cgi", { "get": staffgroups.name + "data","schemata":parent.admin.getcurrentSchemata(), "filter":"id='" + udata[0].id + "'"}, staffgroups.fillform); + module.viewdialog(staffgroups.name); + } + }, + fillform: function(data){ + //console.log("Fill Form 1"); + if (data && data.sqldata){ + //console.log("Fill Form 2"); + fillformbydataclass2(staffgroups.name,staffgroups.choices,data.sqldata[0]); + } + }, + remove: function(){ + var udata = staffgroups.tbl.getSelectedData(); + if (udata[0]) { + var uid = udata[0].id; + showdeletedlg("staffgroups",uid,"Êtes vous sûre de supprimer le departement sélectionné?",staffgroups.afterdeletecallback); + //module.viewpanel('tbl_' + companies.name); + } + }, + saveform: function(){ + //var wpdata = getformcontent(companies.name); + //TODO: save form + //console.log(wpdata); + saveform(stafffroups.name); + staffgroups.gettbldata(); + }, + afterdeletecallback: function(data){ + staffgroups.gettbldata(); + }, + aftersavedcallback: function(){ + + } +} \ No newline at end of file diff --git a/backoffice/tmpl/module/companies/widgets/companies/frm_companies.tt b/backoffice/tmpl/module/companies/widgets/companies/frm_companies.tt deleted file mode 100644 index e3211b28..00000000 --- a/backoffice/tmpl/module/companies/widgets/companies/frm_companies.tt +++ /dev/null @@ -1,35 +0,0 @@ -[% PROCESS macro/fields.tt %] - - diff --git a/backoffice/tmpl/module/companies/widgets/companies/tbar_companies.tt b/backoffice/tmpl/module/companies/widgets/companies/tbar_companies.tt deleted file mode 100644 index 874f57d3..00000000 --- a/backoffice/tmpl/module/companies/widgets/companies/tbar_companies.tt +++ /dev/null @@ -1,7 +0,0 @@ - - \ No newline at end of file diff --git a/backoffice/tmpl/module/companies/widgets/companies/tbl_companies.tt b/backoffice/tmpl/module/companies/widgets/companies/tbl_companies.tt deleted file mode 100644 index 26b61d12..00000000 --- a/backoffice/tmpl/module/companies/widgets/companies/tbl_companies.tt +++ /dev/null @@ -1,3 +0,0 @@ -
-
-
\ No newline at end of file diff --git a/backoffice/tmpl/module/planning/index.tt b/backoffice/tmpl/module/planning/index.tt index ff932298..c695aaab 100644 --- a/backoffice/tmpl/module/planning/index.tt +++ b/backoffice/tmpl/module/planning/index.tt @@ -4,24 +4,30 @@
- + + +
@@ -31,28 +37,30 @@
-