From 2dcfd3f9a031bfae4f1d4523c0ba728bb310d563 Mon Sep 17 00:00:00 2001 From: Kilian Saffran Date: Fri, 19 Mar 2021 02:05:39 +0100 Subject: [PATCH] version 20210319 --- app/data/reports/pot/content.html.mustache | 35 --- app/data/reports/pot/footer.html.mustache | 47 ---- app/data/reports/pot/header.html.mustache | 20 -- app/db.php | 14 +- app/index.php | 20 +- app/js/report.js | 14 -- app/lib/POT/Report.php | 278 ++++++++++++--------- app/lib/POT/Staff.php | 4 +- app/lib/database.php | 5 +- app/lib/helpers.php | 15 ++ app/lib/lang/de.php | 3 +- app/lib/lang/fr.php | 3 +- app/lib/session.php | 4 +- app/report.php | 45 ++-- app/{ => tmpl/module}/js/app.js | 0 app/{ => tmpl/module}/js/dataform.js | 0 app/{ => tmpl/module}/js/request.js | 24 +- app/{ => tmpl/module}/js/sw.js | 0 app/{ => tmpl/module}/js/timecalc.js | 0 app/tmpl/module/periods/reportperiod.js | 18 +- app/tmpl/module/workplans/workplans.js | 3 +- 21 files changed, 255 insertions(+), 297 deletions(-) delete mode 100644 app/data/reports/pot/content.html.mustache delete mode 100644 app/data/reports/pot/footer.html.mustache delete mode 100644 app/data/reports/pot/header.html.mustache delete mode 100644 app/js/report.js rename app/{ => tmpl/module}/js/app.js (100%) rename app/{ => tmpl/module}/js/dataform.js (100%) rename app/{ => tmpl/module}/js/request.js (86%) rename app/{ => tmpl/module}/js/sw.js (100%) rename app/{ => tmpl/module}/js/timecalc.js (100%) diff --git a/app/data/reports/pot/content.html.mustache b/app/data/reports/pot/content.html.mustache deleted file mode 100644 index b9704714..00000000 --- a/app/data/reports/pot/content.html.mustache +++ /dev/null @@ -1,35 +0,0 @@ - - - - PDF - Rapport - Période de Référence - - - - - - diff --git a/app/data/reports/pot/footer.html.mustache b/app/data/reports/pot/footer.html.mustache deleted file mode 100644 index ff0f0e0e..00000000 --- a/app/data/reports/pot/footer.html.mustache +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - -
 
-
Congé: - {{#vleg}} - {{vleg.legend}}) {{vleg.vacancyname}} - {{/vleg}} -
-
Récupération: - $rleg =$this->dbh->queryarray(); - foreach ($rleg as $r){ - $outdata .= $rleg[$r]["legend"].") ".$rleg[$r]["vacancyname"]." "; - } - $outdata .= "
- Page / -
- \ No newline at end of file diff --git a/app/data/reports/pot/header.html.mustache b/app/data/reports/pot/header.html.mustache deleted file mode 100644 index 32e23591..00000000 --- a/app/data/reports/pot/header.html.mustache +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - -
-

{{ reportheading }}

-

-
- {{company}} {{socialtype}}
- {{address}}
- {{zip}} {{city}}

-
-
- \ No newline at end of file diff --git a/app/db.php b/app/db.php index ad0db476..64b508a2 100644 --- a/app/db.php +++ b/app/db.php @@ -28,7 +28,7 @@ $vars["session"] = $se->getSession($vars["sid"]); $sess = $vars["session"]; } else { - error_log("No Session!"); + //error_log("No Session!"); $html["error"] = " No Authorization"; header('Content-Type: application/json'); echo json_encode($html); @@ -37,13 +37,13 @@ $p = json_decode(file_get_contents('php://input'), true); - error_log("params:".print_r($p,true)); + //error_log("params:".print_r($p,true)); #$html["params"] = $p; if (isset($p["get"])){ $retdata = array(); $hres; $schema = "public"; - error_log("'get' isset!"); + //error_log("'get' isset!"); if (isset($p["schemata"])){ $schema = $db->securetext($p["schemata"]); } @@ -263,13 +263,13 @@ } } } - error_log("ident:".print_r($ident,true)); - error_log("DATA:".print_r($data,true)); + //error_log("ident:".print_r($ident,true)); + //error_log("DATA:".print_r($data,true)); //$sql = array(); if (count($data) > 0){ if ($type == "ins"){$sql = $db->createInsertDDL($schema,$table,$data);} else { $sql = $db->createUpdateDDL($schema,$table,$ident,$data);} - error_log("save_form: ".$sql); + //error_log("save_form: ".$sql); #$html["sql"] = \@sql; $retid= $db->exec($sql); $html["result"] = $retid["0"]; @@ -283,7 +283,7 @@ # print STDERR $p["fn"]."\n"; if ($p["fn"] == "setsessiondata"){ $sid = $sess["idsession"]; - error_log(print_r($p["params"],true)); + //error_log(print_r($p["params"],true)); $res = $se->setsessiondata($sid,$p["params"]); $html["result"]["sessiondata"] = $res; } diff --git a/app/index.php b/app/index.php index e2768bff..35703f59 100644 --- a/app/index.php +++ b/app/index.php @@ -18,7 +18,7 @@ if (preg_match('/^POT/',$vars["ua"])){ $vars["realpath"] = $_SERVER['REQUEST_URI']; $vars["filepath"] = substr($_SERVER['REQUEST_URI'],strlen($vars["basepath"])); if ($_SERVER["QUERY_STRING"] != null){ - error_log("has QS:". $_SERVER["QUERY_STRING"]); + //error_log("has QS:". $_SERVER["QUERY_STRING"]); $vars["filepath"] = substr($vars["filepath"],0,strlen($vars["filepath"])-strlen($_SERVER["QUERY_STRING"])-1); } $vars["baseurl"] = $_SERVER["REQUEST_SCHEME"]."://".$_SERVER["HTTP_HOST"].'/'.$vars["basepath"]; @@ -36,9 +36,9 @@ if ($vars["filepath"] != ""){ $vars["page"] = $vars["filepath"]; } $vars["abspath"] = ""; -error_log("FP: ".$vars["filepath"]); -error_log("PAGE: ".$vars["page"]); -error_log("SUFF: ".$vars["suffix"]); +//error_log("FP: ".$vars["filepath"]); +//error_log("PAGE: ".$vars["page"]); +//error_log("SUFF: ".$vars["suffix"]); $vars["sid"] = $_COOKIE[$cfg["cookie"]]; //print STDERR "cookie: ".$vars["cookiename"]." : ".$p["sid"]."\n--\n"; @@ -105,10 +105,10 @@ $vars["session"] = $sess; $vars["ctype"] = 'text/html'; if ($vars["suffix"] == "js"){ $vars["ctype"]= "application/javascript"; - $skl = "file.tt"; + //$skl = "file.tt"; } elseif ($vars["suffix"] == "css"){ $vars["ctype"] = "text/css"; - $skl = "file.tt"; + //$skl = "file.tt"; } header("Content-Type: ".$vars["ctype"]."; charset=utf-8"); //print $cgi->header(-type=>, -charset=>"utf-8", -cookie => $cookie); @@ -129,7 +129,7 @@ $vars["pagename"] = basename($vars["page"]); if ($sess["id"]){ //error_log(print_r($sess,true)); $sdata = json_decode($sess["sessiondata"]); - error_log(print_r($sdata,true)); + //error_log(print_r($sdata,true)); $sma = $sdata->schemata; $vars["schemata"] = $sdata->schemata; $vars["cmpcfg"] = $se->getCompanyConfig($sma); @@ -153,13 +153,13 @@ use Twig\Loader\FilesystemLoader; $loader = new FilesystemLoader($cfg["templatepath"]); $twig = new Environment($loader,['autoescape' => false]); if ($vars["ctype"] == "text/html"){ - error_log("render (SKL) ".$skl); + //error_log("render (SKL) ".$skl); echo $twig->render($skl, $vars); } else { - error_log("render ".$vars["ctype"]." ".$vars["page"]); + //error_log("render ".$vars["ctype"]." ".$vars["page"]); $dd = $twig->render($vars["page"], $vars); - error_log($dd); + //error_log($dd); echo $dd; } if ($vars["ctype"] == 'text/html'){ diff --git a/app/js/report.js b/app/js/report.js deleted file mode 100644 index 9d763aa2..00000000 --- a/app/js/report.js +++ /dev/null @@ -1,14 +0,0 @@ -var report ={ - generate: function(repname,filename,data){ - showdataloaddlg("Création PDF encours","Attendez s.v.p.");//closedataloaddlg(); - console.log() - postData("report.php",{"generate":repname,"file": filename + ".pdf","data":data}).then(data => {closedataloaddlg();;report.openreport(data.result)}).catch(e => {closedataloaddlg();}); - return false; - }, - openreport(data){ - - if (data && data.file){ - window.open(api + "report.php?open=" + encodeURIComponent(data.file)); - } - } -} \ No newline at end of file diff --git a/app/lib/POT/Report.php b/app/lib/POT/Report.php index 63ba84ab..7614a65b 100644 --- a/app/lib/POT/Report.php +++ b/app/lib/POT/Report.php @@ -4,7 +4,7 @@ class Report{ private $dbh; private $cfg; private $legend = array(); - private $report = array("pot" => array("top"=>"20mm","bottom" =>"15mm","left"=>"5mm","right"=>"5mm","size"=>"A4","orientation"=>"Landscape","encoding"=>"ISO-8859-1")); + private $report = array("pot" => array("top"=>"20mm","bottom" =>"15mm","left"=>"25mm","right"=>"5mm","size"=>"A4","orientation"=>"Portrait","encoding"=>"ISO-8859-1")); public function __construct($dblink,$cfg){ $this->dbh = $dblink; $this->cfg = $cfg; @@ -13,51 +13,33 @@ class Report{ $this->conn = null; } - public function createReport($schema,$template,$data){ - $resReports = array(); + public function createReport($schema,$template,$data){ + $resfile = null; + $tmpfile = $template.randStr(10); + $outpath = $this->cfg["datapath"].$schema.'/'.$template; + if (!file_exists($outpath)){ + mkdir($outpath,755,true); + } if ($template =="pot"){ - $repsql = "select srp.id_staff,srp.id_reportperiod,'pot_' || to_char(rp.startdate,'YYYYMMDD') || '-' || to_char(rp.enddate,'YYYYMMDD') || '_' || coalesce(surname || '_','') || coalesce(prename,'') || '.pdf' as fname -from ".$schema.".staffreportperiod srp -join ".$schema.".reportperiod rp on (srp.id_reportperiod=rp.id) -join ".$schema.".staff st on (st.id=srp.id_staff)"; - $wh = array(); - if (count($data["id_staff"]) > 0){ - array_push ($wh,"srp.id_staff in ('".join("','",data["id_staff"])."')"); - } - if (count($data["id_period"]) > 0){ - array_push ($wh,"srp.id_reportperiod in ('".join("','",$data["id_period"])."')"); - } - if (count($wh) > 0){ - $repsql .= implode(' AND ',$wh); - } - $repdata =$this->dbh->queryarray($repsql); - foreach ($repdata as $r){ - $this->printPOTContent($schema,$this->cfg["tmppath"].$tmpfile.".html",$r["id_staff"],$r["id_reportperiod"]); - $this->printPOTHeader($schema,$this->cfg["tmppath"].$tmpfile.".header.html"); - $this->printPOTFooter($schema,$this->cfg["tmppath"].$tmpfile.".footer.html"); - $resfile = $this->createPDF($schema,$template,$r["fname"]); - array_push($resReports,$resfile); - } + $repsql = "select srp.id_staff,srp.id_reportperiod,'pot_' || to_char(rp.startdate,'YYYYMMDD') || '-' || to_char(rp.enddate,'YYYYMMDD') || '_' || coalesce(surname || '_','') || coalesce(prename,'') || '.pdf' as fname from ".$schema.".staffreportperiod srp join ".$schema.".reportperiod rp on (srp.id_reportperiod=rp.id) join ".$schema.".staff st on (st.id=srp.id_staff) where srp.id_staff='".$data["id_staff"]."' and srp.id_reportperiod ='".$data["id_period"]."'"; + $repdata =$this->dbh->query($repsql); + //error_log(print_r($repdata,true)); + $this->printPOTContent($schema,$this->cfg["tmppath"].$tmpfile.".html",$repdata["id_staff"],$repdata["id_reportperiod"]); + $this->printPOTHeader($schema,$this->cfg["tmppath"].$tmpfile.".header.html"); + $this->printPOTFooter($schema,$this->cfg["tmppath"].$tmpfile.".footer.html"); + + $resfile = $this->createPDF($schema,$template,$tmpfile,$outpath.'/'.$repdata["fname"]); } elseif ($template =="tracker"){ } - return $resReports; + return $resfile; } - public function createPDF($schema,$template,$pdfname,$data){ + public function createPDF($schema,$template,$tmpfile,$pdfname){ - $time = time(); - $tmpfile = $template.$time; $r = null; - if ($template =="pot"){ - - - } - - - - //dircopy($self->{tmplpath}.'/'.$template,$this->cfg["tmppath"].'/'.$template); + #dircopy($self->{tmplpath}.'/'.$template,$this->cfg["tmppath"].'/'.$template); if (file_exists($this->cfg["tmppath"].$tmpfile.'.html')){ $cmd = '"'.$this->cfg["toolspath"]."/bin/wkhtmltopdf".'"'; if ($this->report[$template]["bottom"]){ $cmd .= " -B ".$this->report[$template]["bottom"]; } @@ -80,10 +62,10 @@ join ".$schema.".staff st on (st.id=srp.id_staff)"; $r = system($cmd); } if (file_exists($pdfname)){ - unlink($this->cfg["tmppath"].'/'.$tmpfile.'.html'); - unlink($this->cfg["tmppath"].'/'.$tmpfile.'.header.html'); - unlink($this->cfg["tmppath"].'/'.$tmpfile.'.footer.html'); - return $pdfname; + // unlink($this->cfg["tmppath"].'/'.$tmpfile.'.html'); + // unlink($this->cfg["tmppath"].'/'.$tmpfile.'.header.html'); + // unlink($this->cfg["tmppath"].'/'.$tmpfile.'.footer.html'); + return substr($pdfname,strlen($this->cfg["datapath"])) ; } return ""; } @@ -95,7 +77,7 @@ join ".$schema.".staff st on (st.id=srp.id_staff)"; // $self->printContent($schema,$this->cfg["tmppath"].'/'.$template.$$.".html",$inputdata); // $self->printHeader($schema,$this->cfg["tmppath"].'/'.$template.$$.".header.html"); // $self->printFooter($schema,$this->cfg["tmppath"].'/'.$template.$$.".footer.html"); -// //dircopy($self->{tmplpath}.'/'.$template,$this->cfg["tmppath"].'/'.$template); +// #dircopy($self->{tmplpath}.'/'.$template,$this->cfg["tmppath"].'/'.$template); // if ((-e $this->cfg["tmppath"].'/'.$template.$$.'.html')){ // $cmd = '"'.$self->{pdf}->{app}.'"'; // if ($pdfreports->{$template}->{bottom}){ $cmd .= " -B ".$pdfreports->{$template}->{bottom}; } @@ -149,7 +131,7 @@ join ".$schema.".staff st on (st.id=srp.id_staff)"; "; - + file_put_contents($outfile,$outdata); return 1; } @@ -213,7 +195,7 @@ join ".$schema.".staff st on (st.id=srp.id_staff)"; $legend["vacancy"] =$this->dbh->querybykey("id","SELECT id,legend FROM ".$schema.".vacancytypes WHERE isworktime=true order by legend;"); $legend["recup"] =$this->dbh->querybykey("id","SELECT id,legend FROM ".$schema.".vacancytypes WHERE isworktime<>true order by legend;"); - $outdata .= " + $outdata = " @@ -226,12 +208,12 @@ join ".$schema.".staff st on (st.id=srp.id_staff)"; [class^=\"icon-\"], [class*=\" icon-\"] { font-family: 'pot' !important; speak: never; font-style: normal; font-weight: normal; font-variant: normal; text-transform: none; line-height: 1; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } .icon-pause:before { content: \"\e900\"; } div { font-size: 12pt; } - table { font-size: 8pt; border-spacing: 0; border-collapse: collapse; border: none; width: 100%; } + table { font-size: 12pt; border-spacing: 0; border-collapse: collapse; border: none; } th { border: 1px solid black; } - td { text-align: center;vertical-align: top; border: 1px solid black; } + td { text-align: center; vertical-align: top; border: 1px solid black; } .right{ text-align: right; } table.tbinline { border-collapse: collapse; } - /*table.tbinline td { border: 0.5px solid //969696; }*/ + /*table.tbinline td { border: 0.5px solid #969696; }*/ table.tbinline tr:first-child td { border-top: 0; } table.tbinline tr td:first-child { border-left: 0; } table.tbinline tr:last-child td { border-bottom: 0; } @@ -267,12 +249,13 @@ join ".$schema.".staff st on (st.id=srp.id_staff)"; where st.isdeleted is null and id_staff='".$id_staff."' and srp.id_reportperiod='".$id_period."' order by rp.startdate,rp.enddate,st.surname,st.prename;"; $rpdata =$this->dbh->queryarray($sql); - $rpmax = count($rpdata)-1; + //$rpmax = count($rpdata)-1; foreach ($rpdata as $rd){ - $outdata .= $this->ReportPage($schema,$rpdata[$rd]); - if ($rd != $rpmax){ - $outdata .= "
"; - } + //(print_r($rd,true)); + $outdata .= $this->ReportPage($schema,$rd); + // if ($rd != $rpmax){ + // $outdata .= "
"; + // } } $outdata .= ""; file_put_contents($outfile,$outdata); @@ -280,22 +263,52 @@ join ".$schema.".staff st on (st.id=srp.id_staff)"; } public function ReportPage($schema,$data){ - + error_log("Call Report Page!"); $perioddata = $this->getPeriodDays($schema,$data["id_staff"],$data["startdate"],$data["enddate"]); $weeksums = $this->getPeriodWeekSums($schema,$data["id_staff"],$data["startdate"],$data["enddate"]); $tblheader = " + + + + + + + + + + + "; + foreach ($perioddata as $pw){ + if ($pw["dspworkdata"] == null){ + + } else { + $tblheader .= " + + + + + + + + + "; + } + } + + $tblheader .= "
DateHeures de travailPausesCongésRécupTotal
Normalmaladieextra
".$pw["dspdate"]."".$pw["dspworkdata"]."".$pw["dsppausedata"]."".$pw["vacancyhours"]."".$pw["vacillhours"]."".$pw["vacextrahours"]."".$pw["recuperationhours"]."".$pw["dayhours"]."
"; + $tblheader .= " - + - - - - - - - - - + + + + + + + + + "; @@ -308,6 +321,8 @@ join ".$schema.".staff st on (st.id=srp.id_staff)"; foreach ($perioddata as $pw){ $wd = explode(',',','.$pw["weekdates"]); + error_log("WD: ".$pw["daydate"]); + //print STDERR "CWEEKDAY:".$pw["daydate"]."=>".$wd[$wdk]."\n"; if ($wdk == 0 ){ if ($cntr > 6){ @@ -318,24 +333,24 @@ join ".$schema.".staff st on (st.id=srp.id_staff)"; $cntr++; $dspwd = explode(',',$pw["dspweekdates"]); - $txtpage .=" - - - - - - - - - - "; - $wdk = 1; + $txtpage .=" + + + + + + + + + + "; + $wdk = 1; } //print STDERR "CWEEKDAY:".$pw["daydate"]."=>".$wd[$wdk]."\n"; while (($pw["daydate"] != $wd[$wdk]) && $wdk <= "7"){ if ($wdk == 0){$wdk++; next; } if (($pw["daydate"] >= $data["startdate"]) || ($pw["daydate"] <= $data["enddate"])){ - $txtpage .=""; + $txtpage .=""; } $wdk++; @@ -347,11 +362,11 @@ join ".$schema.".staff st on (st.id=srp.id_staff)"; $txtpage .= "
".$data["dspstartdate"]." - ".$data["dspenddate"]."".(($data["staffnumber"] != "")?"".$data["staffnumber"]."":"")." ".$data["surname"]." ".$data["prename"]." ".(($data["matricule"] != "")?"(".$data["matricule"].")":"")."
".$data["dspstartdate"]." - ".$data["dspenddate"]."".(($data["staffnumber"] != "")?"".$data["staffnumber"]."":"")." ".$data["surname"]." ".$data["prename"]." ".(($data["matricule"] != "")?"(".$data["matricule"].")":"")."
LundiMardiMecrediJeudiVendrediSamediDimancheLundiMardiMecrediJeudiVendrediSamediDimancheTotaux
".$dspwd[0]."".$dspwd[1]."".$dspwd[2]."".$dspwd[3]."".$dspwd[4]."".$dspwd[5]."".$dspwd[6]."
".$dspwd[0]."".$dspwd[1]."".$dspwd[2]."".$dspwd[3]."".$dspwd[4]."".$dspwd[5]."".$dspwd[6]." 
   @@ -409,34 +424,34 @@ join ".$schema.".staff st on (st.id=srp.id_staff)"; //print STDERR "WDK: ".$wdk."\n"; if ($wdk >= "0"){ while ($wdk <= "7"){ - $txtpage .=""; + $txtpage .=""; $wdk++; } if ($wdk >= "7"){ $txtpage .= " @@ -448,38 +463,77 @@ join ".$schema.".staff st on (st.id=srp.id_staff)"; $txtpage .= "
- - + + - - + @@ -359,12 +374,12 @@ join ".$schema.".staff st on (st.id=srp.id_staff)";
".$pw["dspworkdata"]."
".$pw["dspworkdata"]."
+
".(($pw["dsppausedata"])?$pw["dsppausedata"]:" ")."
- - @@ -393,12 +408,12 @@ join ".$schema.".staff st on (st.id=srp.id_staff)";
+ ".(($pw["dayhours"])?"
".$pw["dayhours"]."
":" ")."
+ ".(($pw["vacancyhours"])?"
".$pw["vacancyhours"]." ".$this["legend"]["vacancy"][$pw["id_vacancytype"]][legend].")
":" ")."
-
".$weeksums[$ws]["totalhours"]."
+
".$weeksums[$ws]["totalhours"]."
"; - //
".(($weeksums->{$ws}->{diffhours} =="00:00")?"":$weeksums->{$ws}->{diffhours})."
+ //
".(($weeksums->{$ws}->{diffhours} =="00:00")?"":$weeksums->{$ws}->{diffhours})."
} $txtpage .= "
   // // // // // - //
".(($weeksums->{$ws}->{diffhours} =="00:00")?"":$weeksums->{$ws}->{diffhours})."
+ //
".(($weeksums->{$ws}->{diffhours} =="00:00")?"":$weeksums->{$ws}->{diffhours})."
} $txtpage .= "
"; - $ws = $perioddata[$lastpw]["weekstart"]; + $ws = $lastpw["weekstart"]; if (isset($weeksums[$ws])){ $txtpage .= "
-
".$weeksums[$ws]["totalhours"]."
+
".$weeksums[$ws]["totalhours"]."
"; //
- //
".(($weeksums->{$ws}->{recperationhours} =="00:00")?"":$weeksums->{$ws}->{recperationhours})."
+ //
".(($weeksums->{$ws}->{recperationhours} =="00:00")?"":$weeksums->{$ws}->{recperationhours})."
//
- //
".(($weeksums->{$ws}->{vacancyhours} =="00:00")?"":$weeksums->{$ws}->{vacancyhours})."
+ //
".(($weeksums->{$ws}->{vacancyhours} =="00:00")?"":$weeksums->{$ws}->{vacancyhours})."
//
"; // $spt = $data["sums"]; - $txtpage .= " - - + $txtpage .= "
"; + + $txtpage .= "

Résumée / Période de référence

+

Période du ".$data["dspstartdate"]." au ".$data["dspenddate"]."

+

".$data["surname"]." ".$data["prename"]." ".(($data["matricule"] != "")?"(".$data["matricule"].")":"")."

+
Résumée période de référence: ".$data["dspstartdate"]." - ".$data["dspenddate"]."
+ + + + - - - - - - - - - - - - - - - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
heures contractuelles:".$data["contracthours"]." h
heures contractuelles:
heures travaillées:
".$data["contracthours"]."
".$data["workhours"]."
congé maladie:
congé:
congé except.:
".(($data["vacancyill"] != '')?$data["vacancyill"] :"00:00")."
".(($data["vacancynormal"] != '')?$data["vacancynormal"] :"00:00")."
".(($data["vacancyextra"] != '')?$data["vacancyextra"] :"00:00")."
heures
récupérées:
".$data["recuperationhours"]."
 
durée travail
réel prestée:
".$data["totalhours"]."moyenne durée
travail réel:
".$data["avgtotalweekhours"]."décompte reporté:
heures payées:
".(($data["transferedhourscalc"] != '')?$data["transferedhourscalc"]:"00:00")."
".(($data["payedhours"] != '')?$data["payedhours"]:"00:00")."
décompte
fin POT:
".$data["hoursdiff"]."congé suppl. +44h:
congé suppl. dimache travaillé:
".(($data["suppvacancy44hours"] != '')?$data["suppvacancy44hours"]:" ")."
".(($data["suppvacancysunwork"] != '')?$data["suppvacancysunwork"]:" ")."
heures travaillées:".$data["workhours"]." h
congé normal".$data["vacancynormal"]." h
congé maladie".$data["vacancyill"]." h
congé extraordinaire".$data["vacancyextra"]." h
heures récupérées:".$data["recuperationhours"]." h
durée travail réel prestée:".$data["totalhours"]." h
moyenne durée travail réel:".$data["avgtotalweekhours"]." h
décompte reporté:".$data["transferedhourscalc"]." h
heures payées:".$data["payedhours"]."
décompte fin POT:".$data["hoursdiff"]."
congé suppl. +44h:".$data["suppvacancy44hours"]."
congé suppl. dimache travaillé:".$data["suppvacancysunwork"]."
"; return $txtpage; } public function getPeriodDays($schema,$id_staff,$date_start,$date_end){ - $sql = "SELECT pd.id,pd.daydate,pd.id_vacancytype,pd.id_recuperationtype, + $sql = "SELECT pd.id,pd.daydate,pd.id_vacancytype,pd.id_recuperationtype,to_char(pd.daydate, 'DD.MM.YYYY') as dspdate, date(date_trunc('week',pd.daydate)) as weekstart, date_part('isoyear',pd.daydate) || '-' || lpad(date_part('week',pd.daydate)::text, 2, '0') AS dspweekshort, to_char(CASE WHEN pd.vacancyhours::interval = '00:00:00'::interval THEN NULL ELSE pd.vacancyhours END::interval, 'HH24:MI') AS vacancyhours, + to_char(case when pd.vacillhours::interval = '00:00:00'::interval then null else pd.vacillhours end::interval, 'HH24:MI') as vacillhours, + to_char(case when pd.vacextrahours::interval = '00:00:00'::interval then null else pd.vacextrahours end::interval, 'HH24:MI') as vacextrahours, to_char(CASE WHEN pd.dayhours::interval = '00:00:00'::interval THEN NULL ELSE pd.dayhours END::interval, 'HH24:MI') AS dayhours, to_char(case WHEN pd.recuperationhours::interval = '00:00:00'::interval THEN NULL ELSE pd.recuperationhours END::interval, 'HH24:MI') AS recuperationhours, COALESCE((to_char(pd.pausestart1::interval, 'HH24:MI') || '-') || to_char(pd.pauseend1::interval, 'HH24:MI'), '') || COALESCE(((CASE WHEN pd.pausestart1 IS NOT NULL THEN '
' ELSE '' END || to_char(pd.pausestart2::interval, 'HH24:MI')) || '-') || to_char(pd.pauseend2::interval, 'HH24:MI'), '') AS dsppausedata, @@ -501,7 +555,7 @@ join ".$schema.".staff st on (st.id=srp.id_staff)"; } - public function getPeriodWeekSums($schem,$id_staff,$date_start,$date_end){ + public function getPeriodWeekSums($schema,$id_staff,$date_start,$date_end){ $sql = "select ws.weekstart,ws.weekend,ws.calweek,ws.calyear, ws.id_staff ,to_char(ws.vacancyhours,'HH24:MI') as vacancyhours diff --git a/app/lib/POT/Staff.php b/app/lib/POT/Staff.php index 99c074c4..ff678c25 100644 --- a/app/lib/POT/Staff.php +++ b/app/lib/POT/Staff.php @@ -60,8 +60,8 @@ or date((select min(startdate) from ".$schema.".staffcontract where id_staff='". $period = new Period($this->dbh,$this->cfg); foreach ($perioddata as $pp){ - error_log(print_r($perioddata,true)); - error_log(print_r($pp,true)); + //error_log(print_r($perioddata,true)); + //error_log(print_r($pp,true)); $this->dbh->exec("INSERT INTO ".$schema.".staffreportperiod (id_reportperiod, id_staff) VALUES ('".$pp["id"]."','".$id_staff."') on conflict on constraint uniq_staffreportperiod_cal do nothing;"); $period->setStaffPeriodDays($schema,$pp["id"],$id_staff); diff --git a/app/lib/database.php b/app/lib/database.php index 49d9f977..e9eca84f 100644 --- a/app/lib/database.php +++ b/app/lib/database.php @@ -2,7 +2,7 @@ class database { private $conn; private $dbconf; - private $debug=1; + private $debug=0; public function __construct($pdbconf){ $this->dbconf = $pdbconf; try { @@ -124,9 +124,6 @@ class database { return $inssql; } - - - public function newuuid(){ $nid = $this->query("SELECT lower(hex( randomblob(4)) || '-' || hex( randomblob(2)) || '-' || hex( randomblob(2)) || '-' || hex( randomblob(2)) || '-' || hex(randomblob(6))) as id;"); return $nid["id"]; diff --git a/app/lib/helpers.php b/app/lib/helpers.php index 8ecd95ce..d29bf5a6 100644 --- a/app/lib/helpers.php +++ b/app/lib/helpers.php @@ -11,4 +11,19 @@ } return substr( $haystack, -$length ) === $needle; } + + function randStr($qtd){ + //Under the string $Caracteres you write all the characters you want to be used to randomly generate the code. + $Caracteres = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMOPQRSTUVXWYZ0123456789'; + $QuantidadeCaracteres = strlen($Caracteres); + $QuantidadeCaracteres--; + + $Hash=NULL; + for($x=1;$x<=$qtd;$x++){ + $Posicao = rand(0,$QuantidadeCaracteres); + $Hash .= substr($Caracteres,$Posicao,1); + } + + return $Hash; + } ?> \ No newline at end of file diff --git a/app/lib/lang/de.php b/app/lib/lang/de.php index 05424b18..76290703 100644 --- a/app/lib/lang/de.php +++ b/app/lib/lang/de.php @@ -234,5 +234,6 @@ "viewonlyweeks" => "Tage ausblenden", "viewdays" => "Tage einblenden", "otherhours" => "Sonstige", - "otherpaidhours" => "andere bezahlte Stunden" + "otherpaidhours" => "andere bezahlte Stunden", + "createpdf" => "PDF-Erstellung!" ); ?> \ No newline at end of file diff --git a/app/lib/lang/fr.php b/app/lib/lang/fr.php index 923b66c3..8c6196d4 100644 --- a/app/lib/lang/fr.php +++ b/app/lib/lang/fr.php @@ -235,5 +235,6 @@ "viewonlyweeks" => "masquer jours", "viewdays" => "afficher jours", "otherhours" => "Autres", - "otherpaidhours" => "autres heures payés" + "otherpaidhours" => "autres heures payés", + "createpdf" => "Création PDF!" ); ?> \ No newline at end of file diff --git a/app/lib/session.php b/app/lib/session.php index ef035f56..d734a0ff 100644 --- a/app/lib/session.php +++ b/app/lib/session.php @@ -47,10 +47,10 @@ class session { } public function setsessiondata($idsession,$params){ - error_log(print_r($params,true)); + //(print_r($params,true)); $sdata = $this->dbh->query("select sessiondata from public.sessions where id='".$idsession."'"); $nxdata = json_decode($sdata["sessiondata"]); - error_log(print_r($nxdata,true)); + //error_log(print_r($nxdata,true)); //$sdata->sessiondata= $sdata->sessiondata); # print STDERR Dumper($sdata); foreach ($params as $ss => $val){ diff --git a/app/report.php b/app/report.php index 5f4bf1a9..84baeacd 100644 --- a/app/report.php +++ b/app/report.php @@ -25,41 +25,54 @@ if (isset($_COOKIE[$cfg["cookie"]])){ $db = new database($cfg["db"]); $se = new session($db); -$html = array("result" => ""); +$html = array("result" => null); if ($vars["sid"] != ""){ $vars["session"] = $se->getSession($vars["sid"]); $sess = $vars["session"]; } else { - error_log("No Session!"); + //error_log("No Session!"); $html["error"] = " No Authorization"; header('Content-Type: application/json'); echo json_encode($html); exit(0); } $p = json_decode(file_get_contents('php://input'), true); -error_log("params:".print_r($p,true)); +//error_log("params:".print_r($p,true)); if (isset($p["generate"])){ $data = $p["data"]; $schemata = "public"; if (isset($data["schemata"])){ $schemata = $data["schemata"]; } - $tmppath = $cfg["tmppath"]; - $output = $cfg["datapath"].$schemata."/"; - if (!file_exists($tmppath)) { mkdir($tmppath);} - if (!file_exists($output)) { mkdir($output);} - if (!file_exists($output.$p["generate"])){mkdir($output.$p["generate"]);} + //$tmppath = $cfg["tmppath"]; + //$output = $cfg["datapath"].$schemata."/"; + if (!file_exists($cfg["tmppath"])) { mkdir($cfg["tmppath"]);} + //if (!file_exists($output)) { mkdir($output);} + //if (!file_exists($output.$p["generate"])){mkdir($output.$p["generate"]);} $rep = new Report($db,$cfg); - error_log("Create PDF: ".$schemata." ".$p["generate"]." ".$output.dirname($p["generate"].'/'.$schemata.'/'.$p["file"])); - error_log(print_r($data,true)); - $file = $rep->createpdf($schemata,$p["generate"],$output.dirname($p["generate"].'/'.$schemata.'/'.$p["file"]),$data); - $html["result"]["file"] = (($file)?$schemata.'/'.substr($file,strlen($output)):""); + //error_log("Create PDF: ".$schemata." ".$p["generate"]." ".$output.dirname($p["generate"].'/'.$schemata.'/')); + //error_log(print_r($data,true)); + $html["result"]["file"] = $rep->createReport($schemata,$p["generate"],$data); + header("Content-Type: application/json; charset=utf-8"); + echo json_encode($html); } -elseif (isset($p["open"])){ - +elseif (isset($_GET["open"])){ + if (file_exists($cfg["datapath"].'/'.$_GET["open"])){ + //$html["filename"] = basename($_GET["open"]); + //html["filesize"] = filesize($cfg["datapath"].'/'.$_GET["open"]); + $fname = basename($_GET["open"]); + header('Content-Type: application/pdf'); + header('Content-Disposition: inline; filename="'.$fname.'"'); + header('Content-Transfer-Encoding: binary'); + header('Content-Length: ' . filesize($cfg["datapath"].'/'.$_GET["open"])); + header('Accept-Ranges: bytes'); + @readfile($cfg["datapath"].'/'.$_GET["open"]); + } +} else { + header("Content-Type: application/json; charset=utf-8"); + echo json_encode($html); } -header("Content-Type: application/json; charset=utf-8"); -echo json_encode($html); + /* if (exists($p->{generate})){ diff --git a/app/js/app.js b/app/tmpl/module/js/app.js similarity index 100% rename from app/js/app.js rename to app/tmpl/module/js/app.js diff --git a/app/js/dataform.js b/app/tmpl/module/js/dataform.js similarity index 100% rename from app/js/dataform.js rename to app/tmpl/module/js/dataform.js diff --git a/app/js/request.js b/app/tmpl/module/js/request.js similarity index 86% rename from app/js/request.js rename to app/tmpl/module/js/request.js index f45b2c5c..d4b01baa 100644 --- a/app/js/request.js +++ b/app/tmpl/module/js/request.js @@ -11,7 +11,6 @@ async function postData(url = '', data = {}) { credentials: 'same-origin', headers: { 'Content-Type': 'application/json' - }, redirect: 'follow', referrerPolicy: 'strict-origin', @@ -25,17 +24,22 @@ async function postData(url = '', data = {}) { } var report ={ - generate: function(repname,filename,data){ - showdataloaddlg("Création PDF encours","Attendez s.v.p."); - console.log("CREATE PDF",{"generate":repname,"file": filename + ".pdf","data":data}); - postData("report.php",{"generate":repname,"file": filename + ".pdf","data":data}).then (data => {closedataloaddlg();report.openreport(data);}); + generate: function(repname,data){ + showdataloaddlg("{{lbl.createpdf}}","{{lbl.waitmsg}}"); + postData("report.php",{"generate":repname,"data":data}).then (data => { + window.open(api + "report.php?open=" + encodeURIComponent(data.result.file)); + + closedataloaddlg(); + }); return false; }, - openreport(data){ - if (data && data.file){ - window.open(api + "report.php?open=" + encodeURIComponent(data.file)); - } - } + // openreport(data){ + + // if (data && data.file){ + + // } + + // } } async function syncData(url,username,password, data = {}) { diff --git a/app/js/sw.js b/app/tmpl/module/js/sw.js similarity index 100% rename from app/js/sw.js rename to app/tmpl/module/js/sw.js diff --git a/app/js/timecalc.js b/app/tmpl/module/js/timecalc.js similarity index 100% rename from app/js/timecalc.js rename to app/tmpl/module/js/timecalc.js diff --git a/app/tmpl/module/periods/reportperiod.js b/app/tmpl/module/periods/reportperiod.js index 33c5ad8e..9c6c941b 100644 --- a/app/tmpl/module/periods/reportperiod.js +++ b/app/tmpl/module/periods/reportperiod.js @@ -39,8 +39,7 @@ let reportperiod ={ headerFilterPlaceholder:"{{ lbl.filter }}", height: "calc(100vh - 56px)", layout: "fitDataFill", - selectable: true, - selectableRangeMode:"click", + selectable: 1, // rowSelected:function(row){ // console.log("rowselected",row); // if (document.getElementById("pnl_staffperiodweeks").style.cssFloat.display == "block"){ @@ -210,22 +209,11 @@ let reportperiod ={ }, generatereport: function(){ - + let udata = reportperiod.tblfilter.getSelectedData(); let sdata = reportperiod.tbl.getSelectedData(); - let id_staff = []; if (sdata[0]){ - for (var s in sdata){ - id_staff.push(sdata[s].id_staff); - } - } else { - let xdata = reportperiod.tbl.getData(); - for (var s in xdata){ - id_staff.push(xdata[s].id_staff); - } - } - if (udata[0]) { - report.generate('pot',{"schemata":schemata,"id_period":udata[0].id,"id_staff":id_staff}); + report.generate('pot',{"schemata":schemata,"id_period":udata[0].id,"id_staff":sdata[0].id_staff}); } }, datarefresh: function(){ diff --git a/app/tmpl/module/workplans/workplans.js b/app/tmpl/module/workplans/workplans.js index dba80aa8..a1e0ce1f 100644 --- a/app/tmpl/module/workplans/workplans.js +++ b/app/tmpl/module/workplans/workplans.js @@ -216,7 +216,8 @@ let workplans ={ } else { delete wpdata['null']; wpdata["fn"] = 'saveform'; - wpdata['schemata'] = schemata; + wpdata["table"] ="workplans"; + wpdata["schemata"] = schemata; postData("db.php",wpdata).then(data => { document.getElementById('dlg_workplans').style.display='none'; workplans.gettblfilterdata(); -- 2.39.5