v20210407
authorKilian Saffran <ksaffran@dks.lu>
Wed, 7 Apr 2021 08:13:44 +0000 (10:13 +0200)
committerKilian Saffran <ksaffran@dks.lu>
Wed, 7 Apr 2021 08:13:44 +0000 (10:13 +0200)
19 files changed:
app/api.php [new file with mode: 0644]
app/db.php
app/lib/POT/Company.php
app/lib/POT/TimeTracker.php
app/lib/config.php
app/lib/database.php
app/lib/lang/de.php
app/lib/lang/fr.php
app/put.log [new file with mode: 0644]
app/sql.log [new file with mode: 0644]
app/tmpl/module/index.html
app/tmpl/module/js/request.js
app/tmpl/module/staff/pnl_basedata.html
app/tmpl/module/staff/staff.js
app/tmpl/module/timeclock.html
app/tmpl/module/timeclock/timeclock.js [new file with mode: 0644]
dev/db/dev/potlu2_db.public.pg.full.sql
dev/db/live/potlu2_db.brasserie_du_theatrexx.pg.full.sql
test/sendcmd.sh [new file with mode: 0644]

diff --git a/app/api.php b/app/api.php
new file mode 100644 (file)
index 0000000..f44eafa
--- /dev/null
@@ -0,0 +1,71 @@
+<?php\r
+  $mainclasses = scandir("lib");\r
+  foreach ($mainclasses as $key => $value)\r
+  {\r
+   if ((is_file("lib/".$value) && strpos($value,'.') !== 0)  && substr_compare($value, ".php", -strlen(".php")) === 0){\r
+     //error_log("lib/".$value);\r
+     require("lib/".$value);\r
+   }  \r
+  }\r
+  $moduleclasses = scandir("lib/POT");\r
+  foreach ($moduleclasses as $key => $value)\r
+  {\r
+   if ((is_file("lib/POT/".$value) && strpos($value,'.') !== 0)  && substr_compare($value, ".php", -strlen(".php")) === 0){\r
+     //echo $value."<br/>"; \r
+     //error_log("lib/POT/".$value);\r
+      require("lib/POT/".$value);\r
+   }\r
+  }\r
+  $html = array( "result" => null);\r
+  $db = new database($cfg["db"]);\r
+  $tracker = null;\r
+  header('Content-Type: text/plain');\r
+  if (isset($_SERVER["HTTP_POT_TRACKER"]) && isset($_SERVER["HTTP_POT_SCHEMA"]) && isset($_SERVER["HTTP_POT_API_KEY"]) && ($_SERVER["HTTP_USER_AGENT"] == "POT Hourtrax") ){\r
+    $tracker = $db->query("select * from ".$_SERVER["HTTP_POT_SCHEMA"].".timetrackerconfig where trackerhostname='".$_SERVER["HTTP_POT_TRACKER"]."' and authmethod='".$_SERVER["HTTP_POT_API_KEY"]."';");\r
+  }\r
+  //echo print_r($_SERVER,true);\r
+  //echo print_r($_POST,true);\r
+  //echo print_r($tracker,true);\r
+  if (isset($tracker["id"])){\r
+    $p=$_POST;\r
+    if (isset($p["cl"]) && isset($p["fn"]) && $p["cl"] != "database"){\r
+      \r
+      if (class_exists($p["cl"])) {\r
+        //error_log("Class ".$p["cl"]." exists" );\r
+        $strclass=$p["cl"];\r
+        $cl = new $strclass($db,$cfg);\r
+        if (!method_exists($cl,$p["fn"])){\r
+          $html["error"] = "class ".$p["cl"]."->method ".$p["fn"]." does not exist!";\r
+        }\r
+        $r = new ReflectionMethod($strclass, $p["fn"]);\r
+        $metparams = $r->getParameters();\r
+        $fnp = array();\r
+        $prcnt = 0;\r
+        foreach ($metparams as $pp) {\r
+          //error_log("param: ".$pp->getName());\r
+          if (isset($p[$pp->getName()])){\r
+            array_push($fnp,$p[$pp->getName()]);\r
+          }\r
+          if ($pp->isOptional() === false){\r
+            $prcnt++;\r
+          }\r
+          $html["fnparams"][$pp->getName()] = (($pp->isOptional() === true)?"optional":"required");\r
+        }\r
+        //error_log(print_r($fnp,true));\r
+        if (count($fnp) < $prcnt){\r
+          $html["error"] = "Function has ".$prcnt." required parameters!";\r
+        } else {\r
+          echo "call fn";\r
+          $html["result"]["data"] = call_user_func_array(array($cl, $p["fn"]), $fnp);\r
+          //error_log(print_r($html,true));\r
+        }\r
+      } else {\r
+        $html["error"] = "class ".$params["cl"]." does not exist!";\r
+      }\r
+     }\r
+     \r
+     json_encode($html);\r
+  }\r
+  \r
+  \r
+?>
\ No newline at end of file
index efe9433..f6fc02f 100644 (file)
@@ -1,7 +1,7 @@
 <?php
   //  require('lib/vendor/mustache/mustache/src/Mustache/Autoloader.php');
   //  Mustache_Autoloader::register();
-    $mainclasses = scandir("lib");
+   $mainclasses = scandir("lib");
    foreach ($mainclasses as $key => $value)
    {
     if ((is_file("lib/".$value) && strpos($value,'.') !== 0)  && substr_compare($value, ".php", -strlen(".php")) === 0){
     }
     
   }
-  elseif ($p["fn"] == "setnewpassword"){
+  elseif (isset($p["fn"]) && $p["fn"] == "setnewpassword"){
       #$vcode = $se->randomstring(6);
       #$vcode = lc($vcode);
       #$db->exec("UPDATE users set vcode='".$vcode."' where id=".$sess["id"].";");
         #$mret = $eml->sendemail('user_forgotpasswd',$p["email"],$data);
       }
       $html["result"]["data"] = $data;
-  } elseif ($p["fn"] == "genpwd"){
+  } elseif (isset($p["fn"]) && $p["fn"] == "genpwd"){
       $newpwd = $se->randomstring(12);
       $html["result"]["data"]["password"] = $newpwd;
-  } elseif ($p["fn"] == "savenewpwd"){
+  } elseif (isset($p["fn"]) && $p["fn"] == "savenewpwd"){
       if (length($db->securetext($p["pwd"])) > 9){
          $pwd = hash('sha256',$db->securetext($p["pwd"]));
         $db->exec("UPDATE public.users SET userpassword = '".$pwd."' WHERE id='".$db->securetext($p["iduser"])."';");
index 106240c..c134e10 100644 (file)
@@ -176,6 +176,6 @@ on conflict on constraint worktimes_pkey
 do update set
 startdate=excluded.startdate, enddate=excluded.enddate, defaultdayhours=excluded.defaultdayhours, maxdayhours=excluded.maxdayhours, defaultweekhours=excluded.defaultweekhours, maxweekhours=excluded.maxweekhours, maxinterruptionhours=excluded.maxinterruptionhours, isdefault=excluded.isdefault,  mindailyrecuperation=excluded.mindailyrecuperation, maxhourspercents=excluded.maxhourspercents;";
 }
-
 }
 ?>
\ No newline at end of file
index be1c600..e86c795 100644 (file)
@@ -28,7 +28,7 @@ public  function getEmptyTrackDataSet($schema,$idstaff,$daydate){
 }
 
 public  function saveTrackDataSets($schema,$daydate,$idstaff,$trackdata){
-
+   
   //print STDERR Dumper($trackdata);
    $ttids = array();
   foreach ($trackdata as $t ){
@@ -43,6 +43,24 @@ public  function saveTrackDataSets($schema,$daydate,$idstaff,$trackdata){
   return 1;
 }
 
+public function setTracker($schema,$tracker,$data){
+  $atdd = json_decode($data);
+  $tdd= $atdd[0];
+  echo "Set Tracker!\n";
+  //echo print_r($tdd,true);
+  $insnew = "INSERT INTO ".$schema.".timetracker (id,id_staff,daydate,stamp_in,stamp_in_tracker) VALUES ('".$tdd->id."','".$tdd->id_staff."',date('".$tdd->daydate."'),'".$tdd->stamp_in."','".$tracker."') on conflict on constraint timetracker_pkey do nothing;";
+  //echo $insnew."\n";
+  $this->dbh->exec($insnew);
+  if ($tdd["stamp_out"] != null) {
+    $updout= "UPDATE ".$schema.".timetracker SET stamp_out='".$tdd->stamp_out."',stamp_out_tracker='".$tracker."' WHERE id='".$tdd->id."';";
+    //echo $updout."\n",
+    $this->dbh->exec($updout);
+  }
+  
+  return "OK";
+}
+
+
 //   function SyncToTimeTracker(){
 // }
 
@@ -60,14 +78,127 @@ public  function saveTrackDataSets($schema,$daydate,$idstaff,$trackdata){
   return $this->dbh->queryarray($sql);
   }
  
- public function syncToStation($schema,$id_staff){
+ public function getStaffSQL($schema,$trackername,$id_staff = null){
+    $where = "";
+    if ($id_staff != null){
+      $where = "where id_staff in ('".$id_staff."')";
+    } 
+   $stsql = "select id,prename,surname,isdeleted,
+   case when istimetrackenabled is null or timetrackers::text not like '%\"".$trackername."\"%' then true else null end as isdisabled, 
+   timetrackerlang as lang,timetrackerfixtime as fixtime,
+   timetrackerpin as pin, timetrackerrestriction as restriction 
+   from ".$schema.".staff ".$where.";";
+   $stfdata = $this->dbh->queryarray($stsql);
+   $sqldata = "";
+   foreach ($stfdata as $st){
+     $sqldata .= $this->dbh->createReplaceDDL("staff",$st)."\n";
+   }
+
    $syncto="select * from ".$schema.".timetrackersync;"; 
-   $stsql = "select * from  ".$schema.".staff where id='".$id_staff."'";
+   
+   $trackers = $this->dbh->queryarray($syncto);
+   
    #Create SQLITE staff REPLACE TO
-   $worksql = "select * from ".$schema.".staffreportperioddays where id='".$id_staff."' and daydate >= current_date;";
+   $worksql = "select srpd.id,srpd.id_staff,srpd.daydate,srpd.timestart1,srpd.timestart2,srpd.timeend1,srpd.timeend2 from ".$schema.".staffreportperioddays srpd where srpd.daydate >= current_date and id_staff in (select id_staff from ".$schema.".staffreportperioddays where modified > '".$modtime."' group by id_staff);";
+   $wkdata = $this->dbh->queryarray($worksql);
+   foreach ($wkdata as $wk){
+    $sqldata .= $this->dbh->createReplaceDDL("staffworktimes",$wk)."\n";
+   }
+   return $sqldata;
+ }
 
+ public function send_setstaff($schema,$id_staff){
+  $stq = $this->dbh->query("select id, staffnumber,prename,surname,case when istimetrackenabled then 1 else null end as isenabled,timetrackerpin as pin, timetrackerfixtime as fixtime,timetrackerlang as lang, timetrackerrestriction as restriction from ".$schema.".staff where id='".$id_staff."'");
+  $sth = $this->dbh->query("select id,timetrackers from ".$schema.".staff where id='".$id_staff."'");
+  if ($sth["timetrackers"]){
+    $hh = json_decode($sth["timetrackers"]);
+  }
+  if ($stq["id"]){
+    foreach ($stq as $k => $v){
+      $cmd .= $k.'='.$v.";";
+    }
+    $cmd = 'bin/setstaff.sh \''.$cmd.'\'';
+  }
+  
+  //error_log("CMD to SEND:". $cmd);
+  $res = array();
+  foreach ($hh as $host){
+    $res[$host] = $this->exec_curl('{"cl":"ssh","fn":"exec","host":"'.$host.'","cmd":"'.$cmd.'"}');
+  }
+  
+  return $res;
  }
 
+ public function send_cleanfp($schema,$id_staff){
+  $stq = $this->dbh->query("select id,timetrackers from ".$schema.".staff where id='".$id_staff."'");
+  $cmd = 'bin/clearfingerprint.sh '.$id_staff.'';
+  $res = array();
+  $hh = json_decode($stq["timetrackers"]);
+  foreach ($hh as $host){
+    $res[$host] = $this->exec_curl('{"cl":"ssh","fn":"exec","host":"'.$host.'","cmd":"'.$cmd.'"}');
+  }
+  
+  return $res;
+ }
+
+ private function exec_curl($data){
+   $result = null;
+   //error_log("sending to ".$this->cfg["htxurl"]." -> ".$data);
+  try {
+    $curlconn = curl_init();
+    $headers = array();
+    curl_setopt($curlconn, CURLOPT_RETURNTRANSFER, 1);
+    curl_setopt($curlconn, CURLOPT_POST, 1);
+    curl_setopt($curlconn, CURLOPT_USERAGENT, $this->cfg["curlua"]);
+    array_push($headers,'Authorization: Basic '.base64_encode($this->cfg["htxuser"].':'.$this->cfg["htxpwd"]));
+    array_push($headers,'Content-Type: application/json');
+    curl_setopt($curlconn, CURLOPT_HTTPHEADER, $headers);
+    #$fp = fopen(dirname(__FILE__).'/errorlog.txt', 'w');
+      curl_setopt($curlconn, CURLOPT_URL, $this->cfg["htxurl"]);
+      curl_setopt($curlconn, CURLOPT_POSTFIELDS, $data);
+      curl_setopt($curlconn, CURLOPT_VERBOSE, 0);
+    #  curl_setopt($curlconn, CURLOPT_STDERR, $fp);
+      
+      $result = curl_exec($curlconn);
+     
+      if (curl_errno($curlconn)){
+        error_log('Curl Error:'.curl_error($curlconn));
+        return null;
+      }
+  } catch(Exception $e){
+    error_log("CURL init Error : ".$e->getMessage());
+  }
+  return $result;
+ }
+
+ public function getWeekStamps($schema,$date){
+  
+   $xsql = "select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from ".$schema.".staffcontract sc  join ".$schema.".staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('".$date."') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('".$date."') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from ".$schema.".timetracker tt where tt.daydate between date_trunc('week',date('".$date."')) and date(date_trunc('week',date('".$date."')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;";
+   //file_put_contents("sql.log",$schema.$date.$xsql,FILE_APPEND);
+   return $this->dbh->queryarray($xsql);
+ }
+
 
 }
 ?>
index 1745a7d..5090ecd 100644 (file)
       "user" => 'potlu2_user',
       "password" => 'dMY8xGB6cBLzrDGE',
     ),
+    "htxuser" => "htx",
+    "htxpwd" => "Aib5aevo",
+    "htxurl" => "https://htx.plandutravail.lu/htx/api.php",
+    "curlua" => "POT Local Test Server",
     //"liveurl" => "https://app.plandutravail.lu",
     // "cookie" => "potlu140",
     // "db"=> array(
@@ -33,6 +37,7 @@
     //   "user" => 'potlubeta_user',
     //   "password" => 'EHkxYW8gJ7NERu5H',
     // ),
+
     "tmppath" => "data/tmp/",
     "lang" => "de",
     "toolspath" => "tools",
index 87c8a3e..c34456b 100644 (file)
@@ -123,6 +123,17 @@ class database {
     $inssql = "INSERT INTO ".$schema.".".$table." (".implode(",",$dc).") VALUES (".implode(",",$dv).");";
     return $inssql;
   }
+  
+  public function createReplaceDDL($table,$data,$schema=null){
+    $dc = array();
+    $dv = array();
+    foreach ($data as $col => $val){
+      array_push($dc,$col);
+      array_push($dv,$this->value($val));
+    }
+    $replsql = "REPLACE INTO ".(($schema != null)?$schema.".":"").$table." (".implode(",",$dc).") VALUES (".implode(",",$dv).");";
+    return $replsql;
+  }
 
   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;");
index b2d1961..ebbd21d 100644 (file)
@@ -1,6 +1,7 @@
 <?php $lbl = array(\r
   "wdshort" => array("1" => "Mo","2" => "Di","3" => "Mi","4" => "Do", "5" => "Fr", "6" => "Sa", "7" => "So"),\r
   "pot_long" => "Plan d'organisation du travail",\r
+  "home" => "Home",\r
   "weeklytemplates" => "Wochen-Vorlagen",\r
   "template" => "Vorlagen",\r
   "staff" => "Arbeitnehmer",\r
   "partunempl" => "Kurzarbeit",\r
   "normalview" => "Normale Ansicht",\r
   "detailview" => "Detail-Ansicht",\r
-  "trackdiff" => "Stechuhr<br/>Differenz"\r
+  "trackdiff" => "Stechuhr<br/>Differenz",\r
+  "prevweek" => "vorige",\r
+  "nextweek" => "nächste",\r
+  "staffname" => "Name",\r
+  "weektotal" => "Total<br/>Woche",\r
+  "monthdiff" => "Diff<br/>Monat",\r
+  "perioddiff" => "Diff<br/>Periode",\r
+  "updtracker" => "Stechuhr aktualisieren"\r
 ); ?>
\ No newline at end of file
index 72f11c9..1b8dbd1 100644 (file)
   "partunempl" => "Ch. Partielle.",
   "normalview" => "vue normale",
   "detailview" => "vue détaillé",
-  "trackdiff" => "diff.<br/>pointage"
+  "trackdiff" => "diff.<br/>pointage",
+  "prevweek" => "précédant",
+  "nextweek" => "prochaine",
+  "staffname" => "Name",
+  "weektotal" => "Total<br/>Semaine",
+  "monthdiff" => "Diff<br/>mois",
+  "perioddiff" => "Diff<br/>Période",
+  "updtracker" => "màj Pointeuse"
  ); ?>
\ No newline at end of file
diff --git a/app/put.log b/app/put.log
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/app/sql.log b/app/sql.log
new file mode 100644 (file)
index 0000000..330bdb9
--- /dev/null
@@ -0,0 +1,2281 @@
+alicehartmann2021-04-04select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-04-04') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-04-04') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-04-04')) and date(date_trunc('week',date('2021-04-04')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-04-04select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-04-04') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-04-04') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-04-04')) and date(date_trunc('week',date('2021-04-04')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-04-04select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-04-04') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-04-04') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-04-04')) and date(date_trunc('week',date('2021-04-04')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-04-07select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-04-07') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-04-07') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-04-07')) and date(date_trunc('week',date('2021-04-07')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-04-14select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-04-14') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-04-14') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-04-14')) and date(date_trunc('week',date('2021-04-14')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-04-22select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-04-22') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-04-22') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-04-22')) and date(date_trunc('week',date('2021-04-22')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-04-29select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-04-29') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-04-29') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-04-29')) and date(date_trunc('week',date('2021-04-29')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-05-06select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-05-06') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-05-06') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-05-06')) and date(date_trunc('week',date('2021-05-06')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-04-28select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-04-28') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-04-28') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-04-28')) and date(date_trunc('week',date('2021-04-28')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-04-14select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-04-14') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-04-14') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-04-14')) and date(date_trunc('week',date('2021-04-14')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-04-07select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-04-07') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-04-07') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-04-07')) and date(date_trunc('week',date('2021-04-07')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-03-31select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-03-31') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-03-31') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-03-31')) and date(date_trunc('week',date('2021-03-31')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-03-04select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-03-04') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-03-04') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-03-04')) and date(date_trunc('week',date('2021-03-04')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-04-04select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-04-04') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-04-04') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-04-04')) and date(date_trunc('week',date('2021-04-04')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-04-04select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-04-04') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-04-04') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-04-04')) and date(date_trunc('week',date('2021-04-04')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-03-11select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-03-11') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-03-11') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-03-11')) and date(date_trunc('week',date('2021-03-11')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-04-04select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-04-04') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-04-04') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-04-04')) and date(date_trunc('week',date('2021-04-04')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-04-04select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-04-04') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-04-04') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-04-04')) and date(date_trunc('week',date('2021-04-04')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-04-04select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-04-04') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-04-04') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-04-04')) and date(date_trunc('week',date('2021-04-04')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-04-04select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-04-04') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-04-04') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-04-04')) and date(date_trunc('week',date('2021-04-04')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-04-04select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-04-04') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-04-04') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-04-04')) and date(date_trunc('week',date('2021-04-04')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-03-28select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-03-28') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-03-28') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-03-28')) and date(date_trunc('week',date('2021-03-28')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-03-21select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-03-21') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-03-21') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-03-21')) and date(date_trunc('week',date('2021-03-21')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-03-14select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-03-14') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-03-14') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-03-14')) and date(date_trunc('week',date('2021-03-14')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-03-07select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-03-07') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-03-07') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-03-07')) and date(date_trunc('week',date('2021-03-07')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-02-28select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-02-28') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-02-28') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-02-28')) and date(date_trunc('week',date('2021-02-28')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-02-21select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-02-21') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-02-21') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-02-21')) and date(date_trunc('week',date('2021-02-21')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-02-14select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-02-14') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-02-14') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-02-14')) and date(date_trunc('week',date('2021-02-14')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-02-07select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-02-07') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-02-07') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-02-07')) and date(date_trunc('week',date('2021-02-07')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-01-31select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-01-31') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-01-31') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-01-31')) and date(date_trunc('week',date('2021-01-31')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-01-24select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-01-24') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-01-24') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-01-24')) and date(date_trunc('week',date('2021-01-24')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-01-17select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-01-17') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-01-17') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-01-17')) and date(date_trunc('week',date('2021-01-17')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-01-10select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-01-10') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-01-10') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-01-10')) and date(date_trunc('week',date('2021-01-10')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-01-03select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-01-03') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-01-03') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-01-03')) and date(date_trunc('week',date('2021-01-03')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-12-27select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-12-27') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-12-27') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-12-27')) and date(date_trunc('week',date('2020-12-27')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-12-20select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-12-20') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-12-20') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-12-20')) and date(date_trunc('week',date('2020-12-20')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-12-13select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-12-13') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-12-13') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-12-13')) and date(date_trunc('week',date('2020-12-13')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-12-06select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-12-06') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-12-06') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-12-06')) and date(date_trunc('week',date('2020-12-06')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-11-29select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-11-29') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-11-29') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-11-29')) and date(date_trunc('week',date('2020-11-29')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-11-22select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-11-22') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-11-22') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-11-22')) and date(date_trunc('week',date('2020-11-22')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-11-15select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-11-15') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-11-15') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-11-15')) and date(date_trunc('week',date('2020-11-15')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-11-08select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-11-08') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-11-08') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-11-08')) and date(date_trunc('week',date('2020-11-08')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-11-01select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-11-01') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-11-01') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-11-01')) and date(date_trunc('week',date('2020-11-01')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-10-25select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-10-25') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-10-25') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-10-25')) and date(date_trunc('week',date('2020-10-25')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-10-18select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-10-18') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-10-18') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-10-18')) and date(date_trunc('week',date('2020-10-18')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-10-11select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-10-11') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-10-11') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-10-11')) and date(date_trunc('week',date('2020-10-11')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-10-04select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-10-04') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-10-04') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-10-04')) and date(date_trunc('week',date('2020-10-04')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-09-27select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-09-27') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-09-27') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-09-27')) and date(date_trunc('week',date('2020-09-27')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-09-20select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-09-20') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-09-20') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-09-20')) and date(date_trunc('week',date('2020-09-20')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-09-13select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-09-13') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-09-13') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-09-13')) and date(date_trunc('week',date('2020-09-13')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-09-06select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-09-06') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-09-06') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-09-06')) and date(date_trunc('week',date('2020-09-06')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-08-30select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-08-30') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-08-30') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-08-30')) and date(date_trunc('week',date('2020-08-30')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-08-23select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-08-23') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-08-23') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-08-23')) and date(date_trunc('week',date('2020-08-23')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-08-16select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-08-16') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-08-16') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-08-16')) and date(date_trunc('week',date('2020-08-16')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-08-09select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-08-09') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-08-09') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-08-09')) and date(date_trunc('week',date('2020-08-09')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-08-02select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-08-02') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-08-02') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-08-02')) and date(date_trunc('week',date('2020-08-02')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-07-26select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-07-26') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-07-26') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-07-26')) and date(date_trunc('week',date('2020-07-26')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-07-19select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-07-19') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-07-19') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-07-19')) and date(date_trunc('week',date('2020-07-19')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-07-12select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-07-12') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-07-12') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-07-12')) and date(date_trunc('week',date('2020-07-12')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-07-05select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-07-05') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-07-05') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-07-05')) and date(date_trunc('week',date('2020-07-05')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-06-28select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-06-28') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-06-28') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-06-28')) and date(date_trunc('week',date('2020-06-28')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-06-21select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-06-21') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-06-21') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-06-21')) and date(date_trunc('week',date('2020-06-21')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-06-14select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-06-14') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-06-14') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-06-14')) and date(date_trunc('week',date('2020-06-14')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-06-07select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-06-07') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-06-07') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-06-07')) and date(date_trunc('week',date('2020-06-07')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-05-31select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-05-31') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-05-31') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-05-31')) and date(date_trunc('week',date('2020-05-31')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-05-24select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-05-24') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-05-24') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-05-24')) and date(date_trunc('week',date('2020-05-24')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-05-17select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-05-17') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-05-17') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-05-17')) and date(date_trunc('week',date('2020-05-17')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-05-10select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-05-10') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-05-10') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-05-10')) and date(date_trunc('week',date('2020-05-10')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-05-03select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-05-03') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-05-03') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-05-03')) and date(date_trunc('week',date('2020-05-03')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-04-26select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-04-26') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-04-26') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-04-26')) and date(date_trunc('week',date('2020-04-26')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-04-19select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-04-19') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-04-19') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-04-19')) and date(date_trunc('week',date('2020-04-19')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-04-12select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-04-12') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-04-12') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-04-12')) and date(date_trunc('week',date('2020-04-12')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-04-05select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-04-05') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-04-05') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-04-05')) and date(date_trunc('week',date('2020-04-05')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2020-03-29select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2020-03-29') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2020-03-29') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2020-03-29')) and date(date_trunc('week',date('2020-03-29')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-04-04select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-04-04') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-04-04') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-04-04')) and date(date_trunc('week',date('2021-04-04')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-04-11select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-04-11') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-04-11') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-04-11')) and date(date_trunc('week',date('2021-04-11')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-04-18select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-04-18') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-04-18') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-04-18')) and date(date_trunc('week',date('2021-04-18')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-04-25select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-04-25') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-04-25') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-04-25')) and date(date_trunc('week',date('2021-04-25')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-05-02select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-05-02') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-05-02') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-05-02')) and date(date_trunc('week',date('2021-05-02')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-05-09select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-05-09') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-05-09') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-05-09')) and date(date_trunc('week',date('2021-05-09')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-05-16select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-05-16') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-05-16') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-05-16')) and date(date_trunc('week',date('2021-05-16')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-05-09select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-05-09') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-05-09') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-05-09')) and date(date_trunc('week',date('2021-05-09')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-05-02select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-05-02') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-05-02') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-05-02')) and date(date_trunc('week',date('2021-05-02')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-04-25select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-04-25') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-04-25') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-04-25')) and date(date_trunc('week',date('2021-04-25')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-04-18select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-04-18') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-04-18') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-04-18')) and date(date_trunc('week',date('2021-04-18')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-04-11select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-04-11') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-04-11') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-04-11')) and date(date_trunc('week',date('2021-04-11')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-04-04select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-04-04') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-04-04') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-04-04')) and date(date_trunc('week',date('2021-04-04')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-04-11select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-04-11') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-04-11') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-04-11')) and date(date_trunc('week',date('2021-04-11')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-04-18select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-04-18') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-04-18') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-04-18')) and date(date_trunc('week',date('2021-04-18')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-04-25select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-04-25') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-04-25') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-04-25')) and date(date_trunc('week',date('2021-04-25')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-05-02select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-05-02') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-05-02') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-05-02')) and date(date_trunc('week',date('2021-05-02')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-05-09select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-05-09') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-05-09') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-05-09')) and date(date_trunc('week',date('2021-05-09')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-05-16select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-05-16') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-05-16') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-05-16')) and date(date_trunc('week',date('2021-05-16')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-05-23select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-05-23') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-05-23') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-05-23')) and date(date_trunc('week',date('2021-05-23')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-05-30select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-05-30') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-05-30') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-05-30')) and date(date_trunc('week',date('2021-05-30')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-06-06select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-06-06') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-06-06') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-06-06')) and date(date_trunc('week',date('2021-06-06')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-06-13select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-06-13') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-06-13') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-06-13')) and date(date_trunc('week',date('2021-06-13')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-06-20select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-06-20') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-06-20') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-06-20')) and date(date_trunc('week',date('2021-06-20')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-06-13select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-06-13') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-06-13') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-06-13')) and date(date_trunc('week',date('2021-06-13')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-06-06select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-06-06') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-06-06') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-06-06')) and date(date_trunc('week',date('2021-06-06')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-05-30select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-05-30') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-05-30') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-05-30')) and date(date_trunc('week',date('2021-05-30')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-05-23select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-05-23') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-05-23') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-05-23')) and date(date_trunc('week',date('2021-05-23')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-05-16select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-05-16') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-05-16') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-05-16')) and date(date_trunc('week',date('2021-05-16')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-05-09select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-05-09') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-05-09') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-05-09')) and date(date_trunc('week',date('2021-05-09')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-05-02select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-05-02') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-05-02') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-05-02')) and date(date_trunc('week',date('2021-05-02')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-04-25select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-04-25') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-04-25') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-04-25')) and date(date_trunc('week',date('2021-04-25')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-04-18select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-04-18') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-04-18') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-04-18')) and date(date_trunc('week',date('2021-04-18')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-04-11select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-04-11') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-04-11') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-04-11')) and date(date_trunc('week',date('2021-04-11')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-04-18select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-04-18') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-04-18') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-04-18')) and date(date_trunc('week',date('2021-04-18')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-04-25select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-04-25') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-04-25') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-04-25')) and date(date_trunc('week',date('2021-04-25')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-05-02select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-05-02') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-05-02') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-05-02')) and date(date_trunc('week',date('2021-05-02')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-04-25select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-04-25') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-04-25') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-04-25')) and date(date_trunc('week',date('2021-04-25')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-04-18select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-04-18') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-04-18') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-04-18')) and date(date_trunc('week',date('2021-04-18')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;alicehartmann2021-04-04select yy.id_staff,yy.staffname,xx.cw,xx.montime,xx.tuetime,xx.wedtime,xx.thutime,xx.fritime,xx.sattime,xx.suntime,xx.weeksum from (
+    select st.id as id_staff,st.surname || ' ' || st.prename as staffname  from alicehartmann.staffcontract sc  join alicehartmann.staff st on (st.id=sc.id_staff) 
+    where (sc.enddate >= date_trunc('week',date('2021-04-04') + interval '6 days') or enddate is null) and sc.startdate <= date_trunc('week',date('2021-04-04') + interval '6 days')
+    and st.isdeleted is null
+    group by st.id,st.surname,st.prename) yy left join (
+    select id_staff,cw,
+       to_char(sum(case when dow = 1 then daystamptime else null end),'HH24:MI') as montime,
+       to_char(sum(case when dow = 2 then daystamptime else null end),'HH24:MI') as tuetime,
+       to_char(sum(case when dow = 3 then daystamptime else null end),'HH24:MI') as wedtime,
+       to_char(sum(case when dow = 4 then daystamptime else null end),'HH24:MI') as thutime,
+       to_char(sum(case when dow = 5 then daystamptime else null end),'HH24:MI') as fritime,
+       to_char(sum(case when dow = 6 then daystamptime else null end),'HH24:MI') as sattime,
+       to_char(sum(case when dow = 7 then daystamptime else null end),'HH24:MI') as suntime,
+       to_char(sum(daystamptime),'HH24:MI') as weeksum
+        from (
+       select id_staff, 
+       date_part('week',daydate) as cw,
+       sum(coalesce((stamp_out-stamp_in)::interval,'00:00:00')) as daystamptime, 
+       date_part('isodow',daydate) as dow,daydate
+       from alicehartmann.timetracker tt where tt.daydate between date_trunc('week',date('2021-04-04')) and date(date_trunc('week',date('2021-04-04')) + interval '6 days') group by tt.id_staff,daydate
+       ) ttd group by id_staff,cw) xx on yy.id_staff=xx.id_staff;
\ No newline at end of file
index 9cb91e8..d9bb72e 100644 (file)
@@ -28,6 +28,7 @@
       <div class="bar">
         <a class="bar-item bodybtn" href="{{ abspath }}periods.html"><span class="icon icon-calendar" style="font-size: 24px;"></span>{{ lbl.refperiods }}</a>
         <a class="bar-item bodybtn" href="{{ abspath }}staff.html"><span class="icon icon-group" style="font-size: 24px;"></span>{{ lbl.staff }}</a>
+        <a class="bar-item bodybtn" href="{{ abspath }}timeclock.html"><span class="icon icon-star" style="font-size: 24px;"></span>{{ lbl.timetracker }}</a>
       </div>
   </div>
   <div class="card" style="margin-top: 10px;">
index 93abe78..9e7cf5d 100644 (file)
@@ -1,4 +1,4 @@
-var api = location.origin + '/potapp/';
+var api = location.origin + '/';
 // var api2 = location.origin + '/';
 // console.log("API 2",api2);
 var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){var t="";var n,r,i,s,o,u,a;var f=0;e=Base64._utf8_encode(e);while(f<e.length){n=e.charCodeAt(f++);r=e.charCodeAt(f++);i=e.charCodeAt(f++);s=n>>2;o=(n&3)<<4|r>>4;u=(r&15)<<2|i>>6;a=i&63;if(isNaN(r)){u=a=64}else if(isNaN(i)){a=64}t=t+this._keyStr.charAt(s)+this._keyStr.charAt(o)+this._keyStr.charAt(u)+this._keyStr.charAt(a)}return t},decode:function(e){var t="";var n,r,i;var s,o,u,a;var f=0;e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(f<e.length){s=this._keyStr.indexOf(e.charAt(f++));o=this._keyStr.indexOf(e.charAt(f++));u=this._keyStr.indexOf(e.charAt(f++));a=this._keyStr.indexOf(e.charAt(f++));n=s<<2|o>>4;r=(o&15)<<4|u>>2;i=(u&3)<<6|a;t=t+String.fromCharCode(n);if(u!=64){t=t+String.fromCharCode(r)}if(a!=64){t=t+String.fromCharCode(i)}}t=Base64._utf8_decode(t);return t},_utf8_encode:function(e){e=e.replace(/\r\n/g,"\n");var t="";for(var n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r<128){t+=String.fromCharCode(r)}else if(r>127&&r<2048){t+=String.fromCharCode(r>>6|192);t+=String.fromCharCode(r&63|128)}else{t+=String.fromCharCode(r>>12|224);t+=String.fromCharCode(r>>6&63|128);t+=String.fromCharCode(r&63|128)}}return t},_utf8_decode:function(e){var t="";var n=0;var r=c1=c2=0;while(n<e.length){r=e.charCodeAt(n);if(r<128){t+=String.fromCharCode(r);n++}else if(r>191&&r<224){c2=e.charCodeAt(n+1);t+=String.fromCharCode((r&31)<<6|c2&63);n+=2}else{c2=e.charCodeAt(n+1);c3=e.charCodeAt(n+2);t+=String.fromCharCode((r&15)<<12|(c2&63)<<6|c3&63);n+=3}}return t}}
index c07d769..0e5b16f 100644 (file)
@@ -93,6 +93,7 @@
     <div class="third" id="timetrackerconfig" style="display: none;">
       <div class="bar moduletoolbar" >
         <div class="bar-item SubHeadTitle">{{ lbl.timetracker }}</div>
+        <button class="bar-item toolbarbtn right" onclick="staff.sendtotracker(); return false;"><span class="icon icon-clocktime"></span>{{ lbl.updtracker }}</button>
         <button class="bar-item toolbarbtn right" onclick="staff.cleanfingerprints(); return false;"><span class="icon icon-fingerprint-remove"></span>{{ lbl.cleanfp }}</button>
       </div>
       <div class="row" style="margin-top: 5px; margin-bottom: 5px;">
             </div>
             
           </div>
-          <!-- <div class="row"> -->
-            <!-- <div class="container threequarter">
-              <label for="staff_timetrackerlang" class="label">{{ lbl.restriction }}</label>
-              <select class="select data_staff" id="timetrackerrestriction" data-column="timetrackerrestriction"  data-table="staff" data-id="" value="" name="staff_timetrackerrestriction">
-                <option value="">{{ lbl.none }}</option>
-                <option value="onlyworkdays">{{ lbl.onlyworkdays }}</option>
-                <option value="flexworktime">{{ lbl.flexworktime }}</option>
-                <option value="strictworktime">{{ lbl.strictworktime }}</option>
-              </select>
-            </div> -->
-            <!-- <div class="container quarter">
-              
-              
-            </div> -->
-          <!-- </div> -->
-          <div class="row container padding">
+          
+          <!--<div class="row container padding">
             <div class="cell-row">
               <div class="cell" style="width: 40px;">
                 <input class="check  data_staff " id="timetrackerrestriction"  data-column="timetrackerrestriction"  data-table="staff" data-id="" value="onlyworkdays" type="checkbox">
                 Einloggen frühstens erlaubt ? Minuten vor konfigurierter Arbeitzeit. 
               </div>
             </div>                      
-          </div>
+          </div>-->
           <div class="row">
             <div class="container">
               <label for="staff_timetrackers" class="label">{{ lbl.timetrackers }}</label>
index dbaacb9..ffff059 100644 (file)
@@ -190,6 +190,10 @@ let staff ={
       staff.current_id = udata[0].id;
       dataform.cleanform2("staff",staff.choices);
       postData("db.php",{ "get":"staff","schemata":schemata,"id":udata[0].id}).then(data => {
+        console.log("staffdata",data.result.data);
+        if (data.result.data["istimetrackenabled"] == true){
+          data.result.data["istimetrackenabled"] = "1"
+        }
         dataform.fillformbydataclass2("staff",staff.choices,data.result.data,'dataform.savefield(this,null);');
         staffcontract.gettbldata();
         staffperiods.gettbldata();
@@ -247,7 +251,7 @@ let staff ={
     
   },
   getTimeTrackers: function(){
-    postData("db.php",{"get":"getTimeTrackerList","schemata":schemata}).then(data => {
+    postData("db.php",{"cl":"TimeTracker","fn":"getTimeTrackerList","schema":schemata}).then(data => {
       dataform.fillselectlist(staff.choices["timetrackers"],data.result.data,'id','trackername');
     });
   },
@@ -267,6 +271,24 @@ let staff ={
    }
   },
   cleanfingerprints: function(){
-    alert("Noch nicht aktiviert!\nPas activé pour l'instant!")
+    showdataloaddlg('','<div class="xxlarge">{{ lbl.waitmsg }}</div>');
+    postData('db.php',{"cl":"TimeTracker","fn":"send_cleanfp","schema":schemata,"id_staff":staff.current_id}).then(data => {
+      console.log("Clean returns",data);
+      closedataloaddlg();
+    }).catch(err => {
+      closedataloaddlg();
+      console.log("Clean err returns",data);
+    });
+  },
+  sendtotracker: function(){
+    showdataloaddlg('','<div class="xxlarge">{{ lbl.waitmsg }}</div>');
+    postData('db.php',{"cl":"TimeTracker","fn":"send_setstaff","schema":schemata,"id_staff":staff.current_id}).then(data => {
+      console.log("SetStaff returns",data);
+      closedataloaddlg();
+    }).catch(err => {
+      closedataloaddlg();
+      console.log("SetStaff err returns",data);
+    });
+    //alert("Noch nicht aktiviert!\nPas activé pour l'instant!")
   }
 }
index 4e77ce9..289ac16 100644 (file)
@@ -1,9 +1,13 @@
 <div class="display-container">\r
   <div class="bar toolbar">\r
-   <a class="bar-item toolbarbtn" href="{{ abspath }}index.html"><span class="icon icon-back"></span>{{ lbl.back }}</a>\r
+   <a class="bar-item toolbarbtn" href="{{ abspath }}index.html"><span class="icon icon-home"></span>{{ lbl.home }}</a>\r
     <div class="bar-item PageHeadTitle">{{ lbl.timeclock }}</div>\r
+    <button class="bar-item toolbarbtn" onclick="timeclock.prevWeek();"><span class="icon icon-back"></span>{{ lbl.prevweek }}</button>\r
+    <div class="bar-item text-white">Woche:<input type="text" class="input data_week datefield" id="weekselect" name="weekselect" data-column=""  data-table="" data-id=""  value="" /></div>\r
+    <button class="bar-item toolbarbtn" onclick="timeclock.nextWeek();"><span class="icon icon-next"></span>{{ lbl.nextweek }}</button>\r
   </div>\r
 </div>\r
 <div class="display-container">\r
   <div id="tbl_timeclock"></div>\r
-</div>
\ No newline at end of file
+</div>\r
+<script type="text/javascript" src="timeclock/timeclock{{ minify}}.js?v={{ appversion }}"></script>
\ No newline at end of file
diff --git a/app/tmpl/module/timeclock/timeclock.js b/app/tmpl/module/timeclock/timeclock.js
new file mode 100644 (file)
index 0000000..7c7f28c
--- /dev/null
@@ -0,0 +1,90 @@
+function initpage(){\r
+  timeclock.inittable();\r
+}\r
+\r
+let timeclock = {\r
+  tbl: null,\r
+  inittable: function(){\r
+    flatpickr("#weekselect",{altInput: true,\r
+      altFormat: "d.m.Y",\r
+      dateFormat: "Y-m-d",\r
+      "locale": "{{ session.lang }}",\r
+      weekNumbers: true,\r
+      "plugins": [new weekSelect({})],\r
+      "onChange": function(){ timeclock.loadWeek(); }\r
+    });\r
+\r
+    timeclock.tbl = new Tabulator("#tbl_timeclock", {\r
+      headerFilterPlaceholder: "{{ lbl.filter }}",\r
+      height: "calc(100vh - 111px)",\r
+      layout: "fitDataFill",\r
+      selectable: 1,\r
+      // rowDblClick:function(e, row){\r
+      //   //console.log("DBLCLICK",row._row.data.id);\r
+      //   workplans.tbl.selectRow(row._row.data.id);\r
+      //   workplans.edit();\r
+      // },\r
+      rowContext:function(e, row){e.preventDefault(); },\r
+      // groupBy:["weeknum"],\r
+      // groupStartOpen:[true],\r
+      // groupClosedShowCalcs:true,\r
+      // groupHeader:[\r
+      //   function(value, count, data){ \r
+      //     return "Semaine " + value;\r
+      //   },\r
+      // ],\r
+      columns: [\r
+      { title: "{{ lbl.staffname }}",field: "staffname",headerFilter:"input"},\r
+      { title: "{{ lbl.monday }}<br/><span id=\"mondate\">DD.MM.YYYY</span>",field: "montime"},\r
+      { title: "{{ lbl.tuesday }}<br/><span id=\"tuedate\">DD.MM.YYYY</span>",field: "tuetime"},\r
+      { title: "{{ lbl.wednesday }}<br/><span id=\"weddate\">DD.MM.YYYY</span>",field: "wedtime" }, \r
+      { title: "{{ lbl.thursday }}<br/><span id=\"thudate\">DD.MM.YYYY</span>",field: "thutime"}, \r
+      { title: "{{ lbl.friday }}<br/><span id=\"fridate\">DD.MM.YYYY</span>",field: "fritime" },  \r
+      { title: "{{ lbl.saturday }}<br/><span id=\"satdate\">DD.MM.YYYY</span>",field: "sattime" }, \r
+      { title: "{{ lbl.sunday }}<br/><span id=\"sundate\">DD.MM.YYYY</span>",field: "suntime" },\r
+      { title: "{{ lbl.weektotal }}",field: "weeksum"},\r
+      { title: "{{ lbl.monthdiff }}",field: "monthdiff"},\r
+      { title: "{{ lbl.perioddiff }}",field: "perioddiff"}\r
+      ]\r
+  });\r
+    document.getElementById('weekselect')._flatpickr.setDate(moment().format('YYYY-MM-DD'));\r
+    timeclock.gettbldata();\r
+  },\r
+  gettbldata: function(){\r
+    let wsobj = document.getElementById('weekselect').value;\r
+    postData("db.php",{"cl":"TimeTracker","fn":"getWeekStamps","schema":schemata,"date":wsobj}).then(data => {\r
+      let aa = ["mon","tue","wed","thu","fri","sat","sun"];\r
+      let mondate = moment(wsobj).startOf('week').format('YYYY-MM-DD');\r
+      for (var d=0;d<aa.length;d++){\r
+        upddate = moment(mondate).add(d,'days').format('DD.MM.YYYY');\r
+        document.getElementById(aa[d] + "date").innerHTML=upddate;\r
+      }\r
+      console.log(data);\r
+      timeclock.tbl.setData(data.result.data);\r
+    });\r
+  },\r
+  prevWeek: function(){\r
+    let date = document.getElementById("weekselect").value;\r
+    date = moment(date).subtract(7,'days').format('YYYY-MM-DD');\r
+    document.getElementById('weekselect')._flatpickr.setDate(date);\r
+    timeclock.loadWeek();\r
+  },\r
+  nextWeek: function(){\r
+    let date = document.getElementById("weekselect").value;\r
+    date = moment(date).add(7,'days').format('YYYY-MM-DD');\r
+    document.getElementById('weekselect')._flatpickr.setDate(date);\r
+    timeclock.loadWeek();\r
+  },\r
+  loadWeek: function(){\r
+    let date = document.getElementById("weekselect").value;\r
+    let monday = moment(date).startOf('week').format('YYYY-MM-DD');\r
+    let sunday = moment(date).endOf('week').format('YYYY-MM-DD');\r
+    console.log("M:" +monday + "- Date:"+ date + " - S:" + sunday);\r
+    timeclock.gettbldata();\r
+  }\r
+}\r
+\r
+let boldFormatter = function(cell, formatterParams){\r
+  cell.getElement().style.fontWeight="bold";\r
+  return cell.getValue();\r
+};
\ No newline at end of file
index 29c287c..0dd85d6 100644 (file)
@@ -147,16 +147,16 @@ $$;
 
 CREATE FUNCTION public.interval_to_char(itime interval) RETURNS text
     LANGUAGE plpgsql
-    AS $$
-declare 
-       txtval text;
-begin
-       txtval := to_char(itime,'HH24:MI');
-       if (position( '-' in txtval) > 0) then
-               txtval := '-' || replace(txtval,'-','');
-       end if;
-       return txtval;
-end;
+    AS $$\r
+declare \r
+       txtval text;\r
+begin\r
+       txtval := to_char(itime,'HH24:MI');\r
+       if (position( '-' in txtval) > 0) then\r
+               txtval := '-' || replace(txtval,'-','');\r
+       end if;\r
+       return txtval;\r
+end;\r
 $$;
 
 
index 6169715..897761f 100644 (file)
@@ -29,11 +29,11 @@ CREATE SCHEMA brasserie_du_theatrexx;
 
 CREATE FUNCTION brasserie_du_theatrexx.trg_before_upd_schematable() RETURNS trigger
     LANGUAGE plpgsql
-    AS $$
-    begin
-           new.modified = now();
-        RETURN NEW;
-    END;
+    AS $$\r
+    begin\r
+           new.modified = now();\r
+        RETURN NEW;\r
+    END;\r
 $$;
 
 
diff --git a/test/sendcmd.sh b/test/sendcmd.sh
new file mode 100644 (file)
index 0000000..554f4a3
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+AUTH=$(echo -n htx:Aib5aevo | base64)
+curl \
+  -A "DKS POT TestTool" \
+  -H "Authorization: Basic $AUTH" \
+  --header "Content-Type: application/json" \
+  --request POST \
+  --data '{"cl":"ssh","fn":"exec","host":"dhart-pot03","cmd":"bin/clearfingerprint.sh 6f8036b4-338f-a581-2256-4e8c59646836"}' \
+https://htx.plandutravail.lu/htx/api.php
\ No newline at end of file