version 20210319
authorKilian Saffran <ksaffran@dks.lu>
Fri, 19 Mar 2021 01:05:39 +0000 (02:05 +0100)
committerKilian Saffran <ksaffran@dks.lu>
Fri, 19 Mar 2021 01:05:39 +0000 (02:05 +0100)
21 files changed:
app/data/reports/pot/content.html.mustache [deleted file]
app/data/reports/pot/footer.html.mustache [deleted file]
app/data/reports/pot/header.html.mustache [deleted file]
app/db.php
app/index.php
app/js/report.js [deleted file]
app/lib/POT/Report.php
app/lib/POT/Staff.php
app/lib/database.php
app/lib/helpers.php
app/lib/lang/de.php
app/lib/lang/fr.php
app/lib/session.php
app/report.php
app/tmpl/module/js/app.js [moved from app/js/app.js with 100% similarity]
app/tmpl/module/js/dataform.js [moved from app/js/dataform.js with 100% similarity]
app/tmpl/module/js/request.js [moved from app/js/request.js with 86% similarity]
app/tmpl/module/js/sw.js [moved from app/js/sw.js with 100% similarity]
app/tmpl/module/js/timecalc.js [moved from app/js/timecalc.js with 100% similarity]
app/tmpl/module/periods/reportperiod.js
app/tmpl/module/workplans/workplans.js

diff --git a/app/data/reports/pot/content.html.mustache b/app/data/reports/pot/content.html.mustache
deleted file mode 100644 (file)
index b970471..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-<!DOCTYPE html>
-  <html>
-  <head>
-  <title>PDF - Rapport - P&eacute;riode de R&eacute;f&eacute;rence</title>
-  <style>
-  \@font-face {
-  font-family: 'pot'; src: url("data:font/ttf;base64,AAEAAAALAIAAAwAwT1MvMg8SBSoAAAC8AAAAYGNtYXAXVtKHAAABHAAAAFRnYXNwAAAAEAAAAXAAAAAIZ2x5Zq3RsYsAAAF4AAAB0GhlYWQZavrxAAADSAAAADZoaGVhB4IDxgAAA4AAAAAkaG10eAoAAEAAAAOkAAAAFGxvY2EAKAD8AAADuAAAAAxtYXhwAAkAigAAA8QAAAAgbmFtZVKkxIkAAAPkAAABVnBvc3QAAwAAAAAFPAAAACAAAwMAAZAABQAAApkCzAAAAI8CmQLMAAAB6wAzAQkAAAAAAAAAAAAAAAAAAAABEAAAAAAAAAAAAAAAAAAAAABAAADpAAPA/8AAQAPAAEAAAAABAAAAAAAAAAAAAAAgAAAAAAADAAAAAwAAABwAAQADAAAAHAADAAEAAAAcAAQAOAAAAAoACAACAAIAAQAg6QD//f//AAAAAAAg6QD//f//AAH/4xcEAAMAAQAAAAAAAAAAAAAAAQAB//8ADwABAAAAAAAAAAAAAgAANzkBAAAAAAEAAAAAAAAAAAACAAA3OQEAAAAAAQAAAAAAAAAAAAIAADc5AQAAAAADAED/wAPAA8AACgA3AIcAAAEOAQczMjY1NCYjJSIGBw4BBw4BNz4BNQ4BBxYXHgEXFjMyNz4BNzY3LgEnDgEHDgE3PgE1LgEjEzIWBwYHBhYXFhceARUOAQczMhYVFAYrAQYHDgEHBiMiJy4BJyYnNDc+ATc2Ny4BJyY2Nz4BMzIWBwYHBhYXFhc+ATMyFhcuAScmNjc+ATMDLAoZEEUfLS0f/oMQHw8BGR4HNBEbFGJtCgYYGFI7O0xMOztSGBgFCFtRAxkbCDMRGxQXMRudCQgILgwLDA8PB2mGAgYDBzZMTDZgGyAgSCgoKklBQGciIwsTFEYwMDkJGQcPKDMEFQkJCAksDAwKDg8IESERFywVCRgHDyc0BBQJAWsqTiQuICAu0gEBHDQXBwMOFTAZCy8OCQ4NGQkJCQkZDQ4JDSoMGS8VBwMOFTEaAgMBgwUHIygnVCorKRBDKhUnFE44OE4yKCc4Dw8rK5dnZ3cXFBQiDA0HHz8eQWAoAwUFByInJlIpKigBAQICHj4dQWAoAwUAAAEAAAABAACaNXijXw889QALBAAAAAAA20XbOgAAAADbRds6AAD/wAPAA8AAAAAIAAIAAAAAAAAAAQAAA8D/wAAABAAAAAAAA8AAAQAAAAAAAAAAAAAAAAAAAAUEAAAAAAAAAAAAAAACAAAABAAAQAAAAAAACgAUAB4A6AABAAAABQCIAAMAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAADgCuAAEAAAAAAAEAAwAAAAEAAAAAAAIABwA8AAEAAAAAAAMAAwAqAAEAAAAAAAQAAwBRAAEAAAAAAAUACwAJAAEAAAAAAAYAAwAzAAEAAAAAAAoAGgBaAAMAAQQJAAEABgADAAMAAQQJAAIADgBDAAMAAQQJAAMABgAtAAMAAQQJAAQABgBUAAMAAQQJAAUAFgAUAAMAAQQJAAYABgA2AAMAAQQJAAoANAB0cG90AHAAbwB0VmVyc2lvbiAxLjAAVgBlAHIAcwBpAG8AbgAgADEALgAwcG90AHAAbwB0cG90AHAAbwB0UmVndWxhcgBSAGUAZwB1AGwAYQBycG90AHAAbwB0Rm9udCBnZW5lcmF0ZWQgYnkgSWNvTW9vbi4ARgBvAG4AdAAgAGcAZQBuAGUAcgBhAHQAZQBkACAAYgB5ACAASQBjAG8ATQBvAG8AbgAuAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==") format('truetype');
-  font-weight: normal; font-style: normal; font-display: block;
-  }
-  [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%; }
-  th { 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 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; }
-  table.tbinline tr td:last-child { border-right: 0; }
-  td.datavalues div { font-size: 8pt; }
-
-  table { page-break-inside:avoid!important; }
-  tr    { page-break-inside:avoid!important; page-break-after:avoid!important; }
-  thead { display:table-header-group }
-  tfoot { display:table-footer-group }
-  .page-break  { display: inline-block; page-break-before: always!important; }
-  </style>
-  </head>
-  <body>
-  
-  
-  </body></html>
diff --git a/app/data/reports/pot/footer.html.mustache b/app/data/reports/pot/footer.html.mustache
deleted file mode 100644 (file)
index ff0f0e0..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-<!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <script>
- function st() {
-    var vars = {};
-    var query_strings_from_url = document.location.search.  public function string(1).split('&');
-    for (var query_string in query_strings_from_url) {
-        if (query_strings_from_url.hasOwnProperty(query_string)) {
-            var temp_var = query_strings_from_url[query_string].split('=', 2);
-            vars[temp_var[0]] = decodeURI(temp_var[1]);
-        }
-    }
-    var css_selector_classes = ['page', 'frompage', 'topage', 'webpage', 'section', '  public function section', 'date', 'isodate', 'time', 'title', 'doctitle', 'sitepage', 'sitepages'];
-    for (var css_class in css_selector_classes) {
-        if (css_selector_classes.hasOwnProperty(css_class)) {
-            var element = document.getElementsByClassName(css_selector_classes[css_class]);
-            for (var j = 0; j < element.length; ++j) {
-                element[j].textContent = vars[css_selector_classes[css_class]];
-            }
-        }
-    }
- }
- </script></head>
- <body style="border:0; margin: 0;" onload="st()">
- <table style="width: 100%;" >
-  <tr><td colspan="2" style="text-align: right;font-size: 8pt;"><span class="date"></span>&nbsp;<span class="time"></span></td></tr>
-  <tr>
-    <td style="text-align:left;font-size: 6pt;">
-   <div>Congé:  
-    {{#vleg}}
-      {{vleg.legend}}) {{vleg.vacancyname}}
-   {{/vleg}}
-    </div>
-   <div>Récupération:
-    $rleg =$this->dbh->queryarray();
-    foreach ($rleg as $r){
-     $outdata .= $rleg[$r]["legend"].") ".$rleg[$r]["vacancyname"]." ";
-    }
-   $outdata .= "</div></td>
-    <td style="text-align:right;font-size: 8pt;">
-      Page <span class="page"></span>/<span class="topage"></span>
-    </td>
-  </tr>
- </table>
- </body></html>
\ 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 (file)
index 32e2359..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-<!DOCTYPE html>
-  <html><head>
-  <meta charset="UTF-8">
-  </head><body style="border:0; margin: 0;">
-  <table style="width: 100%;">
-  <tr>
-    <td style="width: 150mm; margin-top:5mm;">
-      <h4>{{ reportheading }}<h4>
-    </td>
-    <td style="width: 60mm;text-align: right;">
-      <div style="text-align: left;width: 60mm; font-size: 8pt;font: sans;">
-          <b>{{company}} {{socialtype}}</b><br/>
-          {{address}}<br/> 
-          {{zip}} {{city}}<br/><br/>
-      </div>
-    </td>
-    <tr><td style="text-align: left;"></td><td></td></tr>
-  </tr>
-  </table>
-  </body></html>
\ No newline at end of file
index ad0db47..64b508a 100644 (file)
@@ -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);
  $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"]);
     }
           }
       }
       }
-      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"];
     # 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;
     }
index e2768bf..35703f5 100644 (file)
@@ -18,7 +18,7 @@ if (preg_match('/^POT/',$vars["ua"])){
 $vars["realpath"] = $_SERVER['REQUEST_URI'];\r
 $vars["filepath"] = substr($_SERVER['REQUEST_URI'],strlen($vars["basepath"])); \r
 if ($_SERVER["QUERY_STRING"] != null){\r
-  error_log("has QS:". $_SERVER["QUERY_STRING"]);\r
+  //error_log("has QS:". $_SERVER["QUERY_STRING"]);\r
   $vars["filepath"] = substr($vars["filepath"],0,strlen($vars["filepath"])-strlen($_SERVER["QUERY_STRING"])-1);\r
 }\r
 $vars["baseurl"] = $_SERVER["REQUEST_SCHEME"]."://".$_SERVER["HTTP_HOST"].'/'.$vars["basepath"];\r
@@ -36,9 +36,9 @@ if ($vars["filepath"] != ""){
   $vars["page"] = $vars["filepath"];\r
 }\r
 $vars["abspath"] = "";\r
-error_log("FP: ".$vars["filepath"]);\r
-error_log("PAGE: ".$vars["page"]);\r
-error_log("SUFF: ".$vars["suffix"]);\r
+//error_log("FP: ".$vars["filepath"]);\r
+//error_log("PAGE: ".$vars["page"]);\r
+//error_log("SUFF: ".$vars["suffix"]);\r
 \r
 $vars["sid"] = $_COOKIE[$cfg["cookie"]];\r
 //print STDERR "cookie: ".$vars["cookiename"]." : ".$p["sid"]."\n--\n";\r
@@ -105,10 +105,10 @@ $vars["session"] = $sess;
 $vars["ctype"] = 'text/html';\r
 if ($vars["suffix"] == "js"){\r
   $vars["ctype"]= "application/javascript";\r
-  $skl = "file.tt";\r
+  //$skl = "file.tt";\r
 } elseif ($vars["suffix"] == "css"){\r
   $vars["ctype"] = "text/css";\r
-  $skl = "file.tt";\r
+  //$skl = "file.tt";\r
 }\r
 header("Content-Type: ".$vars["ctype"]."; charset=utf-8");\r
 //print $cgi->header(-type=>, -charset=>"utf-8", -cookie => $cookie);\r
@@ -129,7 +129,7 @@ $vars["pagename"] = basename($vars["page"]);
 if ($sess["id"]){\r
   //error_log(print_r($sess,true));\r
   $sdata = json_decode($sess["sessiondata"]);\r
-  error_log(print_r($sdata,true));\r
+  //error_log(print_r($sdata,true));\r
   $sma = $sdata->schemata;\r
   $vars["schemata"] = $sdata->schemata;\r
   $vars["cmpcfg"] = $se->getCompanyConfig($sma);\r
@@ -153,13 +153,13 @@ use Twig\Loader\FilesystemLoader;
 $loader = new FilesystemLoader($cfg["templatepath"]);\r
 $twig = new Environment($loader,['autoescape' => false]);\r
 if ($vars["ctype"] == "text/html"){\r
-  error_log("render (SKL) ".$skl);\r
+  //error_log("render (SKL) ".$skl);\r
   echo $twig->render($skl, $vars);\r
 } else {\r
-  error_log("render ".$vars["ctype"]." ".$vars["page"]);\r
+  //error_log("render ".$vars["ctype"]." ".$vars["page"]);\r
 \r
   $dd = $twig->render($vars["page"], $vars);\r
-  error_log($dd);\r
+  //error_log($dd);\r
   echo $dd;\r
 }\r
 if ($vars["ctype"] == 'text/html'){\r
diff --git a/app/js/report.js b/app/js/report.js
deleted file mode 100644 (file)
index 9d763aa..0000000
+++ /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
index 63ba84a..7614a65 100644 (file)
@@ -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)";
   </tr>
   </table>
   </body></html>";
-  
+  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 = "
   <!DOCTYPE html>
   <html>
   <head>
@@ -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 .= "<div class=\"page-break\"></div>";
-    }
+    //(print_r($rd,true));
+    $outdata .= $this->ReportPage($schema,$rd);
+    // if ($rd != $rpmax){
+    //   $outdata .= "<div class=\"page-break\"></div>";
+    // }
   }
   $outdata .= "</body></html>";
   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 = "<table>
+      <thead>
+      <tr>
+        <th rowspan=\"2\" style=\"width: 30mm;\">Date</th>
+        <th rowspan=\"2\">Heures de travail</th>
+        <th rowspan=\"2\">Pauses</th>
+        <th colspan=\"3\">Cong&eacute;s</th>
+        <th rowspan=\"2\">R&eacute;cup</th>
+        <th rowspan=\"2\">Total</th>
+      </tr>
+      <tr><th>Normal</th><th>maladie</th><th>extra</th></tr>
+      </thead></tbody>";
+    foreach ($perioddata as $pw){
+      if ($pw["dspworkdata"] == null){
+
+      } else {
+        $tblheader .= "<tr>
+        <td style=\"vertical-align: middle;width: 25mm;height: 9mm;\">".$pw["dspdate"]."</td>
+        <td style=\"vertical-align: middle;font-size: 10pt;width: 35mm;\">".$pw["dspworkdata"]."</td>
+        <td style=\"vertical-align: middle;font-size: 8pt; width: 25mm;\">".$pw["dsppausedata"]."</td>
+        <td style=\"vertical-align: middle;width: 18mm;\">".$pw["vacancyhours"]."</td>
+        <td style=\"vertical-align: middle;width: 18mm;\">".$pw["vacillhours"]."</td>
+        <td style=\"vertical-align: middle;width: 18mm;\">".$pw["vacextrahours"]."</td>
+        <td style=\"vertical-align: middle;width: 18mm;\">".$pw["recuperationhours"]."</td>
+        <td style=\"vertical-align: middle;width: 18mm; font-weight: bold;\">".$pw["dayhours"]."</td>
+        </tr>";
+      }
+    }
+    
+    $tblheader .= "</tbody></table>";
+    $tblheader .= "<table>
     <thead>
-      <tr ><th colspan=\"4\" style=\"border-right: 0px;font-size: 10pt;\">".$data["dspstartdate"]." - ".$data["dspenddate"]."</th><th colspan=\"3\" style=\"border-left: 0px;font-size: 10pt;\">".(($data["staffnumber"] != "")?"".$data["staffnumber"]."":"")." ".$data["surname"]." ".$data["prename"]." ".(($data["matricule"] != "")?"(".$data["matricule"].")":"")."</th></tr>
+      <tr ><th colspan=\"4\" style=\"border-right: 0px;font-size: 10pt;\">".$data["dspstartdate"]." - ".$data["dspenddate"]."</th><th colspan=\"4\" style=\"border-left: 0px;font-size: 10pt;\">".(($data["staffnumber"] != "")?"".$data["staffnumber"]."":"")." ".$data["surname"]." ".$data["prename"]." ".(($data["matricule"] != "")?"(".$data["matricule"].")":"")."</th></tr>
       <tr>
-      <!--<th style=\"background-color: //e6e6e6;\">Semaine</th>-->
-      <th style=\"background-color: //e6e6e6;\">Lundi</th>
-      <th style=\"background-color: //e6e6e6;\">Mardi</th>
-      <th style=\"background-color: //e6e6e6;\">Mecredi</th>
-      <th style=\"background-color: //e6e6e6;\">Jeudi</th>
-      <th style=\"background-color: //e6e6e6;\">Vendredi</th>
-      <th style=\"background-color: //e6e6e6;\">Samedi</th>
-      <th style=\"background-color: //e6e6e6;\">Dimanche</th>
-      <!--<th style=\"background-color: //e6e6e6;\">Totaux</th>-->
+      <!--<th style=\"background-color: #e6e6e6;\">Semaine</th>-->
+      <th style=\"background-color: #e6e6e6;\">Lundi</th>
+      <th style=\"background-color: #e6e6e6;\">Mardi</th>
+      <th style=\"background-color: #e6e6e6;\">Mecredi</th>
+      <th style=\"background-color: #e6e6e6;\">Jeudi</th>
+      <th style=\"background-color: #e6e6e6;\">Vendredi</th>
+      <th style=\"background-color: #e6e6e6;\">Samedi</th>
+      <th style=\"background-color: #e6e6e6;\">Dimanche</th>
+      <th style=\"background-color: #e6e6e6;\">Totaux</th>
       </tr>
     </thead>
     <tbody>";
@@ -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 .="<tr>
-        <!--<th rowspan=\"2\" style=\"background-color: //e6e6e6;\">".$pw["dspweekshort"]."</th>-->
-          <th style=\"width: 44mm;background-color: //e6e6e6;\">".$dspwd[0]."</th>
-          <th style=\"width: 44mm;background-color: //e6e6e6;\">".$dspwd[1]."</th>
-          <th style=\"width: 44mm;background-color: //e6e6e6;\">".$dspwd[2]."</th>
-          <th style=\"width: 44mm;background-color: //e6e6e6;\">".$dspwd[3]."</th>
-          <th style=\"width: 44mm;background-color: //e6e6e6;\">".$dspwd[4]."</th>
-          <th style=\"width: 44mm;background-color: //e6e6e6;\">".$dspwd[5]."</th>
-          <th style=\"width: 44mm;background-color: //e6e6e6;\">".$dspwd[6]."</th>
-          <!--<th style=\"background-color: //e6e6e6;\">&nbsp;</th></tr><tr>-->
-        ";
-        $wdk = 1; 
+        $txtpage .="<tr>
+        <!--<th rowspan=\"2\" style=\"background-color: #e6e6e6;\">".$pw["dspweekshort"]."</th>-->
+          <th style=\"width: 44mm;background-color: #e6e6e6;\">".$dspwd[0]."</th>
+          <th style=\"width: 44mm;background-color: #e6e6e6;\">".$dspwd[1]."</th>
+          <th style=\"width: 44mm;background-color: #e6e6e6;\">".$dspwd[2]."</th>
+          <th style=\"width: 44mm;background-color: #e6e6e6;\">".$dspwd[3]."</th>
+          <th style=\"width: 44mm;background-color: #e6e6e6;\">".$dspwd[4]."</th>
+          <th style=\"width: 44mm;background-color: #e6e6e6;\">".$dspwd[5]."</th>
+          <th style=\"width: 44mm;background-color: #e6e6e6;\">".$dspwd[6]."</th>
+          <th style=\"background-color: #e6e6e6;\">&nbsp;</th>
+          </tr><tr>";
+          $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 .="<td style=\"max-height: 15px!important;height: 15mm;background-color: //d6d6d6;\">&nbsp;</td>";
+              $txtpage .="<td style=\"max-height: 15px!important;height: 15mm;background-color: #d6d6d6;\">&nbsp;</td>";
             } 
             
             $wdk++; 
@@ -347,11 +362,11 @@ join ".$schema.".staff st on (st.id=srp.id_staff)";
           $txtpage .= "<td style=\"max-height: 15px!important; height: 15mm;\">
           <table class=\"tbinline\" style=\"height: 15mm;\" style=\"border: 0px;\"><tr style=\"border: 0px;\"><td style=\"border: 0px;\">
           <table class=\"tbinline\">
-            <tr style=\" border-bottom: 0.5px solid //969696;\" >
-              <td class=\"datavalues\" style=\"height: 8mm;border-right: 0.5px solid //969696;\"><div>".$pw["dspworkdata"]."</div></td>
+            <tr style=\" border-bottom: 0.5px solid #969696;\" >
+              <td class=\"datavalues\" style=\"height: 8mm;border-right: 0.5px solid #969696;\"><div>".$pw["dspworkdata"]."</div></td>
             </tr>
-            <tr style=\"border-right: 0.5px solid //969696;\">
-              <td class=\"datavalues\" style=\"height: 7mm;border-right: 0.5px solid //969696;\">
+            <tr style=\"border-right: 0.5px solid #969696;\">
+              <td class=\"datavalues\" style=\"height: 7mm;border-right: 0.5px solid #969696;\">
                 <div style=\"font-size: 6pt;\">".(($pw["dsppausedata"])?$pw["dsppausedata"]:"&nbsp;")."</div>
               </td>
             </tr>
@@ -359,12 +374,12 @@ join ".$schema.".staff st on (st.id=srp.id_staff)";
           </td><td style=\"width: 15mm;border: 0px; \">
           <table class=\"tbinline\" style=\"border: 0px;\">
             <tr>
-              <td class=\"datavalues\"  style=\"height: 5mm;border-bottom: 0.5px solid //969696;border-right: 0;\"\">
+              <td class=\"datavalues\"  style=\"height: 5mm;border-bottom: 0.5px solid #969696;border-right: 0;\"\">
                 ".(($pw["dayhours"])?"<div style=\"font-weight: bold;\">".$pw["dayhours"]."</div>":"&nbsp;")."
               </td>
             </tr>
             <tr>  
-              <td class=\"datavalues\"  style=\"height: 5mm;border-bottom: 0.5px solid //969696;border-right: 0;\">
+              <td class=\"datavalues\"  style=\"height: 5mm;border-bottom: 0.5px solid #969696;border-right: 0;\">
                 ".(($pw["vacancyhours"])?"<div style=\"font-style: bold;\">".$pw["vacancyhours"]." <sup>".$this["legend"]["vacancy"][$pw["id_vacancytype"]][legend].")</sup></div>":"&nbsp;")."
               </td>
             </tr>
@@ -393,12 +408,12 @@ join ".$schema.".staff st on (st.id=srp.id_staff)";
              <table class=\"tbinline\">
             <tr>
               <td class=\"datavalues\"  style=\"height: 5mm;\">
-              <div style=\"font-weight: bold;border-bottom: 0.5px solid //969696;\">".$weeksums[$ws]["totalhours"]."</div>
+              <div style=\"font-weight: bold;border-bottom: 0.5px solid #969696;\">".$weeksums[$ws]["totalhours"]."</div>
               </td>
             </tr>
             </table>
             ";
-            //<div style=\"font-weight: bold;text-decoration: underline;text-decoration-style: double;border-bottom: 0.5px solid //969696;\">".(($weeksums->{$ws}->{diffhours} =="00:00")?"":$weeksums->{$ws}->{diffhours})."</div>
+            //<div style=\"font-weight: bold;text-decoration: underline;text-decoration-style: double;border-bottom: 0.5px solid #969696;\">".(($weeksums->{$ws}->{diffhours} =="00:00")?"":$weeksums->{$ws}->{diffhours})."</div>
           }
           $txtpage .= "</td></tr></table>
           </td></tr>
@@ -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 .="<td style=\"height: 15mm;background-color: //d6d6d6;\">&nbsp;</td>";
+          $txtpage .="<td style=\"height: 15mm;background-color: #d6d6d6;\">&nbsp;</td>";
          $wdk++;
       }
       if ($wdk >= "7"){
          $txtpage .=  "<td class=\"datavalues\">
           <table  class=\"tbinline\"><tr><td class=\"datavalues\">";
-          $ws = $perioddata[$lastpw]["weekstart"];
+          $ws = $lastpw["weekstart"];
           if (isset($weeksums[$ws])){
             $txtpage .= "
              <table class=\"tbinline\">
             <tr>
               <td class=\"datavalues\"  style=\"height: 5mm;\">
-              <div style=\"font-weight: bold;border-bottom: 0.5px solid //969696;\">".$weeksums[$ws]["totalhours"]."</div>
+              <div style=\"font-weight: bold;border-bottom: 0.5px solid #969696;\">".$weeksums[$ws]["totalhours"]."</div>
               </td>
             </tr>
             </table>
             ";
             // <tr>
             //   <td class=\"datavalues\"  style=\"height: 5mm;\">
-            //   <div style=\"font-weight: bold;text-decoration: underline;border-bottom: 0.5px solid //969696;\">".(($weeksums->{$ws}->{recperationhours} =="00:00")?"":$weeksums->{$ws}->{recperationhours})."</div>
+            //   <div style=\"font-weight: bold;text-decoration: underline;border-bottom: 0.5px solid #969696;\">".(($weeksums->{$ws}->{recperationhours} =="00:00")?"":$weeksums->{$ws}->{recperationhours})."</div>
             //   </td>
             // </tr>
             // <tr>
             //   <td class=\"datavalues\"  style=\"height: 5mm;\">
-            // <div style=\"font-weight: bold;font-style: italic;border-bottom: 0.5px solid //969696;\">".(($weeksums->{$ws}->{vacancyhours} =="00:00")?"":$weeksums->{$ws}->{vacancyhours})."</div>
+            // <div style=\"font-weight: bold;font-style: italic;border-bottom: 0.5px solid #969696;\">".(($weeksums->{$ws}->{vacancyhours} =="00:00")?"":$weeksums->{$ws}->{vacancyhours})."</div>
             // </td>
             // </tr>
-            //<div style=\"font-weight: bold;text-decoration: underline;text-decoration-style: double;border-bottom: 0.5px solid //969696;\">".(($weeksums->{$ws}->{diffhours} =="00:00")?"":$weeksums->{$ws}->{diffhours})."</div>
+            //<div style=\"font-weight: bold;text-decoration: underline;text-decoration-style: double;border-bottom: 0.5px solid #969696;\">".(($weeksums->{$ws}->{diffhours} =="00:00")?"":$weeksums->{$ws}->{diffhours})."</div>
           }
           $txtpage .= "</td></tr></table>
           </td></tr>
@@ -448,38 +463,77 @@ join ".$schema.".staff st on (st.id=srp.id_staff)";
    $txtpage .= "</tbody> </table>";
 
   // $spt = $data["sums"];
-  $txtpage .= "<table>
-    <thead>
-    <tr><th colspan=\"20\">R&eacute;sum&eacute;e p&eacute;riode de r&eacute;f&eacute;rence: ".$data["dspstartdate"]." - ".$data["dspenddate"]."</th></tr>
+  $txtpage .= "<div style = \"display:block; clear:both; page-break-after:always;\"></div>";
+
+  $txtpage .= "<h2>R&eacute;sum&eacute;e / P&eacute;riode de r&eacute;f&eacute;rence</h2>
+  <h3>P&eacute;riode du ".$data["dspstartdate"]." au ".$data["dspenddate"]."</h3>
+  <h4>".$data["surname"]." ".$data["prename"]." ".(($data["matricule"] != "")?"(".$data["matricule"].")":"")."</h4>
+    <table style=\"width: unset!important;\">
+    <tbody>
+    <tr>
+      <td style=\"text-align: left;vertical-align: top; width: 70mm;padding: 5px;padding-left: 15px; \">heures contractuelles:</td>
+      <td style=\"text-align: right; width: 30mm; font-weight: bold; padding: 5px;padding-left: 15px;\">".$data["contracthours"]." h</td></tr>
     <tr>
-      <td style=\"text-align: right;background-color: //e6e6e6;\">heures contractuelles:<br/>heures travaill&eacute;es:</td>
-      <th style=\"width: 15mm;\">".$data["contracthours"]."<br/>".$data["workhours"]."</th>
-      <td style=\"text-align: right;background-color: //e6e6e6;\">cong&eacute; maladie:<br>cong&eacute;:<br>congé except.:</td>
-      <th style=\"width: 15mm;\">".(($data["vacancyill"] != '')?$data["vacancyill"] :"00:00")."<br>".(($data["vacancynormal"] != '')?$data["vacancynormal"] :"00:00")."<br>".(($data["vacancyextra"] != '')?$data["vacancyextra"] :"00:00")."</th>
-      <td style=\"text-align: right;background-color: //e6e6e6;\">heures<br/>r&eacute;cup&eacute;r&eacute;es:</td>
-      <th style=\"width: 15mm;\">".$data["recuperationhours"]."<br/>&nbsp;</th>
-      <td style=\"text-align: right;background-color: //e6e6e6;\">dur&eacute;e travail<br/>r&eacute;el prest&eacute;e:</td>
-      <th style=\"width: 15mm;\">".$data["totalhours"]."</th>
-      <td style=\"text-align: right;background-color: //e6e6e6;\">moyenne dur&eacute;e<br/>travail r&eacute;el:</td>
-      <th style=\"width: 15mm;\">".$data["avgtotalweekhours"]."</th>
-      <td style=\"text-align: right;background-color: //e6e6e6;\">d&eacute;compte report&eacute;:<br/>heures pay&eacute;es:</td>
-      <th style=\"width: 15mm;\">".(($data["transferedhourscalc"] != '')?$data["transferedhourscalc"]:"00:00")."<br/>".(($data["payedhours"] != '')?$data["payedhours"]:"00:00")."</th>
-      <td style=\"text-align: right;background-color: //e6e6e6;\">d&eacute;compte<br/>fin POT:</td>
-      <th style=\"width: 15mm;\">".$data["hoursdiff"]."</th>
-      <td style=\"text-align: right;background-color: //e6e6e6;\">cong&eacute; suppl. +44h:<br/>cong&eacute; suppl. dimache travaill&eacute;:</td>
-      <th style=\"width: 15mm;\">".(($data["suppvacancy44hours"] != '')?$data["suppvacancy44hours"]:"&nbsp;")."<br/>".(($data["suppvacancysunwork"] != '')?$data["suppvacancysunwork"]:"&nbsp;")."</th>
+      <td style=\"text-align: left;vertical-align: top; padding: 5px; width: 70mm;padding: 5px;padding-left: 15px;\">heures travaill&eacute;es:</td>
+      <td style=\"text-align: right; width: 30mm; font-weight: bold;padding: 5px;padding-left: 15px; \">".$data["workhours"]." h</td>
     </tr>
-    </thead>
+    <tr>
+      <td style=\"text-align: left;vertical-align: top; padding: 5px; width: 70mm;padding: 5px;padding-left: 15px;\">cong&eacute; normal</td>
+      <td style=\"text-align: right; width: 30mm; font-weight: bold;padding: 5px;padding-left: 15px; \">".$data["vacancynormal"]." h</td>
+    </tr>
+    <tr>
+      <td style=\"text-align: left;vertical-align: top; padding: 5px; width: 70mm;padding: 5px;padding-left: 15px;\">cong&eacute; maladie</td>
+      <td style=\"text-align: right; width: 30mm; font-weight: bold;padding: 5px;padding-left: 15px; \">".$data["vacancyill"]." h</td>
+    </tr>
+    <tr>
+      <td style=\"text-align: left;vertical-align: top; padding: 5px; width: 70mm;padding: 5px;padding-left: 15px;\">cong&eacute; extraordinaire</td>
+      <td style=\"text-align: right; width: 30mm; font-weight: bold;padding: 5px;padding-left: 15px; \">".$data["vacancyextra"]." h</td>
+    </tr>
+    <tr>
+      <td style=\"text-align: left;vertical-align: top; padding: 5px; width: 70mm;padding: 5px;padding-left: 15px;\">heures r&eacute;cup&eacute;r&eacute;es:</td>
+      <td style=\"text-align: right; width: 30mm; font-weight: bold;padding: 5px;padding-left: 15px; \">".$data["recuperationhours"]." h</td>
+    </tr>
+    <tr>
+      <td style=\"text-align: left;vertical-align: top; padding: 5px; width: 70mm;padding: 5px;padding-left: 15px;\">dur&eacute;e travail r&eacute;el prest&eacute;e:</td>
+      <td style=\"text-align: right; width: 30mm; font-weight: bold;padding: 5px;padding-left: 15px; \">".$data["totalhours"]." h</td>
+    </tr>
+    <tr>
+      <td style=\"text-align: left;vertical-align: top; padding: 5px; width: 70mm;padding: 5px;padding-left: 15px;\">moyenne dur&eacute;e travail r&eacute;el:</td>
+      <td style=\"text-align: right; width: 30mm; font-weight: bold;padding: 5px;padding-left: 15px; \">".$data["avgtotalweekhours"]." h</td>
+    </tr>
+    <tr>
+      <td style=\"text-align: left;vertical-align: top; padding: 5px; width: 70mm;padding: 5px;padding-left: 15px;\">d&eacute;compte report&eacute;:</td> 
+      <td style=\"text-align: right; width: 30mm; font-weight: bold;padding: 5px;padding-left: 15px; \">".$data["transferedhourscalc"]." h</td>
+    </tr>
+    <tr>
+      <td style=\"text-align: left;vertical-align: top; padding: 5px; width: 70mm;padding: 5px;padding-left: 15px;\">heures pay&eacute;es:</td>
+      <td style=\"text-align: right; width: 30mm; font-weight: bold;padding: 5px;padding-left: 15px;\">".$data["payedhours"]."</td>
+    </tr>
+    <tr>
+      <td style=\"text-align: left;vertical-align: top; padding: 5px; width: 70mm;padding: 5px;padding-left: 15px;\">d&eacute;compte fin POT:</td>
+      <td style=\"text-align: right; width: 30mm; font-weight: bold;padding: 5px;padding-left: 15px;\">".$data["hoursdiff"]."</td>
+    </tr>
+    <tr>
+      <td style=\"text-align: left;vertical-align: top; padding: 5px; width: 70mm;\">cong&eacute; suppl. +44h:</td>
+      <td style=\"text-align: center; width: 30mm; font-weight: bold;padding: 5px;padding-left: 15px;\">".$data["suppvacancy44hours"]."</td>
+    </tr>
+    <tr>
+      <td style=\"text-align: left;vertical-align: top; padding: 5px; width: 70mm;\">cong&eacute; suppl. dimache travaill&eacute;:</td>
+      <td style=\"text-align: center; width: 30mm; font-weight: bold;padding: 5px;padding-left: 15px;\">".$data["suppvacancysunwork"]."</td>
+    </tr>
+    </tbody>
   </table>";
 
   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 '<br/>' 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
index 99c074c..ff678c2 100644 (file)
@@ -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);
index 49d9f97..e9eca84 100644 (file)
@@ -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"];
index 8ecd95c..d29bf5a 100644 (file)
     }
    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
index 05424b1..7629070 100644 (file)
   "viewonlyweeks" => "Tage ausblenden",\r
   "viewdays" => "Tage einblenden",\r
   "otherhours" => "Sonstige",\r
-  "otherpaidhours" => "andere bezahlte Stunden"\r
+  "otherpaidhours" => "andere bezahlte Stunden",\r
+  "createpdf" => "PDF-Erstellung!"\r
 ); ?>
\ No newline at end of file
index 923b66c..8c6196d 100644 (file)
   "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
index ef035f5..d734a0f 100644 (file)
@@ -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){
index 5f4bf1a..84baeac 100644 (file)
@@ -25,41 +25,54 @@ if (isset($_COOKIE[$cfg["cookie"]])){
 $db = new database($cfg["db"]);\r
 $se = new session($db);\r
 \r
-$html = array("result" =>  "");\r
+$html = array("result" =>  null);\r
 if ($vars["sid"] != ""){\r
   $vars["session"] = $se->getSession($vars["sid"]);\r
   $sess = $vars["session"];\r
 } else {\r
-  error_log("No Session!"); \r
+  //error_log("No Session!"); \r
   $html["error"] = " No Authorization";\r
   header('Content-Type: application/json');\r
   echo json_encode($html);\r
   exit(0);\r
  }\r
 $p = json_decode(file_get_contents('php://input'), true);\r
-error_log("params:".print_r($p,true));\r
+//error_log("params:".print_r($p,true));\r
 if (isset($p["generate"])){\r
   $data = $p["data"];\r
   $schemata = "public";\r
   if (isset($data["schemata"])){\r
     $schemata = $data["schemata"];\r
   }\r
-  $tmppath = $cfg["tmppath"];\r
-  $output = $cfg["datapath"].$schemata."/";\r
-  if (!file_exists($tmppath)) { mkdir($tmppath);}\r
-  if (!file_exists($output)) { mkdir($output);}\r
-  if (!file_exists($output.$p["generate"])){mkdir($output.$p["generate"]);}\r
+  //$tmppath = $cfg["tmppath"];\r
+  //$output = $cfg["datapath"].$schemata."/";\r
+  if (!file_exists($cfg["tmppath"])) { mkdir($cfg["tmppath"]);}\r
+  //if (!file_exists($output)) { mkdir($output);}\r
+  //if (!file_exists($output.$p["generate"])){mkdir($output.$p["generate"]);}\r
   $rep = new Report($db,$cfg);\r
-  error_log("Create PDF: ".$schemata." ".$p["generate"]." ".$output.dirname($p["generate"].'/'.$schemata.'/'.$p["file"]));\r
-  error_log(print_r($data,true));\r
-  $file = $rep->createpdf($schemata,$p["generate"],$output.dirname($p["generate"].'/'.$schemata.'/'.$p["file"]),$data);\r
-  $html["result"]["file"] = (($file)?$schemata.'/'.substr($file,strlen($output)):"");\r
+  //error_log("Create PDF: ".$schemata." ".$p["generate"]." ".$output.dirname($p["generate"].'/'.$schemata.'/'));\r
+  //error_log(print_r($data,true));\r
+  $html["result"]["file"] = $rep->createReport($schemata,$p["generate"],$data);\r
+  header("Content-Type: application/json; charset=utf-8");\r
+  echo json_encode($html);  \r
 }\r
-elseif (isset($p["open"])){\r
-\r
+elseif (isset($_GET["open"])){\r
+  if (file_exists($cfg["datapath"].'/'.$_GET["open"])){\r
+    //$html["filename"] = basename($_GET["open"]);\r
+    //html["filesize"] = filesize($cfg["datapath"].'/'.$_GET["open"]);\r
+    $fname = basename($_GET["open"]);\r
+    header('Content-Type: application/pdf');\r
+    header('Content-Disposition: inline; filename="'.$fname.'"');\r
+    header('Content-Transfer-Encoding: binary');\r
+    header('Content-Length: ' . filesize($cfg["datapath"].'/'.$_GET["open"]));\r
+    header('Accept-Ranges: bytes');\r
+    @readfile($cfg["datapath"].'/'.$_GET["open"]);\r
+  }\r
+} else {\r
+  header("Content-Type: application/json; charset=utf-8");\r
+  echo json_encode($html);\r
 }\r
-header("Content-Type: application/json; charset=utf-8");\r
-echo json_encode($html);\r
+\r
   /*\r
   \r
   if (exists($p->{generate})){\r
similarity index 100%
rename from app/js/app.js
rename to app/tmpl/module/js/app.js
similarity index 86%
rename from app/js/request.js
rename to app/tmpl/module/js/request.js
index f45b2c5..d4b01ba 100644 (file)
@@ -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 = {}) {
similarity index 100%
rename from app/js/sw.js
rename to app/tmpl/module/js/sw.js
index 33c5ad8..9c6c941 100644 (file)
@@ -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(){
index dba80aa..a1e0ce1 100644 (file)
@@ -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();