From: Kilian Saffran Date: Thu, 27 Jan 2022 14:42:21 +0000 (+0100) Subject: v202201271541 t1.14.0 X-Git-Url: http://cloud.dks.lu/git/?a=commitdiff_plain;h=fb81b26b8752d82a767118315121cade216dfac5;p=pot_lu.git v202201271541 t1.14.0 --- diff --git a/app/bin/conf.sh b/app/bin/conf.sh new file mode 100644 index 00000000..e4979860 --- /dev/null +++ b/app/bin/conf.sh @@ -0,0 +1,20 @@ +DBNAME="potlu2_db" +DBUSER="potlu2_user" +DBPWD="dMY8xGB6cBLzrDGE" +export PGPASSWORD="dMY8xGB6cBLzrDGE" +DBLIVEHOST="sql12.your-server.de" +DBDEVHOST="dks-laptop" +DBSCHEMA="public" +DBREFSCHEMA="alicehartmann" +REMOTEAPPFOLDER="public_html/app_plandutravail_lu" +REMOTEWEBSITEFOLDER="public_html/plandutravail_lu" +SSHUSER="dksalu" +SSHPORT="222" +SSHHOST="www422.your-server.de" +TMPDIR=${CALLDIR}"/tmp" +if [ ! -d "${TMPDIR}" ] +then + mkdir -p "${TMPDIR}" +fi +APPDIR=$( dirname "${CALLDIR}" )"/app" +WEBDIR=$( dirname "${CALLDIR}" )"/website" \ No newline at end of file diff --git a/app/bin/sectorworktimes.sql b/app/bin/sectorworktimes.sql new file mode 100644 index 00000000..ec3c80f0 --- /dev/null +++ b/app/bin/sectorworktimes.sql @@ -0,0 +1,18 @@ +INSERT INTO public.sectorworktime +(id, sector, startdate, enddate, defaultdayhours, maxdayhours, defaultweekhours, maxweekhours, maxinterruptionhours, isdefault, mindailyrecuperation, maxhourspercents, periodtype, description, freq) VALUES (getuuid(), 'HORESCA', date(date('$EASTERMONDAY') - interval '9 days') , date(date('$EASTERMONDAY') - interval '6 days'), '08:00:00'::interval, '12:00:00'::interval, '40:00:00'::interval, '51:00:00'::interval, '03:00:00'::interval, NULL, '11:00:00', NULL, '<15', 'Lundi de paques -9 jours / Lundi de paques +6 jours', NULL), +(getuuid(), 'HORESCA', date(date('$EASTERMONDAY') - interval '9 days') , date(date('$EASTERMONDAY') - interval '6 days'), '08:00:00'::interval, '12:00:00'::interval, '40:00:00'::interval, '51:00:00'::interval, '03:00:00'::interval, NULL, '11:00:00', NULL, '>=50', 'Lundi de paques -9 jours / Lundi de paques +6 jours', NULL), +(getuuid(), 'HORESCA', '$YEAR-12-23', date(date('$YEAR-01-02') + interval '1 year'), '08:00:00'::interval, '12:00:00'::interval, '40:00:00'::interval, '51:00:00'::interval, '03:00:00'::interval, NULL, '11:00:00', NULL, '15-49', '23 déc. / 02 janv.', NULL), +(getuuid(), 'HORESCA', '$YEAR-06-01', '$YEAR-06-30', '08:00:00'::interval, '12:00:00'::interval, '40:00:00'::interval, '51:00:00'::interval, '03:00:00'::interval, NULL, '11:00:00', NULL, '<15', 'mois juin', NULL), +(getuuid(), 'HORESCA', '$YEAR-12-23', date(date('$YEAR-01-02') + interval '1 year'), '08:00:00'::interval, '12:00:00'::interval, '40:00:00'::interval, '51:00:00'::interval, '03:00:00'::interval, NULL, '11:00:00', NULL, '<15', '23 déc. / 02 janv.', NULL), +(getuuid(), 'HORESCA', '$YEAR-06-01', '$YEAR-06-30', '08:00:00'::interval, '12:00:00'::interval, '40:00:00'::interval, '51:00:00'::interval, '03:00:00'::interval, NULL, '11:00:00', NULL, '>=50', 'mois juin', NULL), +(getuuid(), 'HORESCA', '$YEAR-06-01', '$YEAR-06-30', '08:00:00'::interval, '12:00:00'::interval, '40:00:00'::interval, '51:00:00'::interval, '03:00:00'::interval, NULL, '11:00:00', NULL, '15-49', 'mois juin', NULL), +(getuuid(), 'HORESCA', '$YEAR-12-23', date(date('$YEAR-01-02') + interval '1 year'), '08:00:00'::interval, '12:00:00'::interval, '40:00:00'::interval, '51:00:00'::interval, '03:00:00'::interval, NULL, '11:00:00', NULL, '>=50', '23 déc. / 02 janv.', NULL), +(getuuid(), 'HORESCA', date(date('$EASTERMONDAY') - interval '9 days') , date(date('$EASTERMONDAY') - interval '6 days'), '08:00:00'::interval, '12:00:00'::interval, '40:00:00'::interval, '51:00:00'::interval, '03:00:00'::interval, NULL, '11:00:00', NULL, '15-49', 'Lundi de paques -9 jours / Lundi de paques +6 jours', NULL), +(getuuid(), 'HORESCA', '$YEAR-07-01', '$YEAR-07-31', '08:00:00'::interval, '12:00:00'::interval, '40:00:00'::interval, '54:00:00'::interval, '03:00:00'::interval, NULL, '11:00:00', NULL, '<15', 'mois juillet', NULL), +(getuuid(), 'HORESCA', '$YEAR-08-01', '$YEAR-08-31', '08:00:00'::interval, '12:00:00'::interval, '40:00:00'::interval, '54:00:00'::interval, '03:00:00'::interval, NULL, '11:00:00', NULL, '<15', 'mois aout', NULL), +(getuuid(), 'HORESCA', '$YEAR-09-01', '$YEAR-09-30', '08:00:00'::interval, '12:00:00'::interval, '40:00:00'::interval, '51:00:00'::interval, '03:00:00'::interval, NULL, '11:00:00', NULL, '>=50', 'mois septembre', NULL), +(getuuid(), 'HORESCA', '$YEAR-09-01', '$YEAR-09-30', '08:00:00'::interval, '12:00:00'::interval, '40:00:00'::interval, '51:00:00'::interval, '03:00:00'::interval, NULL, '11:00:00', NULL, '<15', 'mois septembre', NULL), +(getuuid(), 'HORESCA', '$YEAR-09-01', '$YEAR-09-30', '08:00:00'::interval, '12:00:00'::interval, '40:00:00'::interval, '51:00:00'::interval, '03:00:00'::interval, NULL, '11:00:00', NULL, '15-49', 'mois septembre', NULL), +(getuuid(), 'HORESCA', date(date('$EASTERMONDAY') + interval '50 days' - interval '9 days') , date(date('$EASTERMONDAY') + interval '50 days' - interval '6 days'), '08:00:00'::interval, '12:00:00'::interval, '40:00:00'::interval, '51:00:00'::interval, '03:00:00'::interval, NULL, '11:00:00', NULL, '15-49', 'Lundi de pentecote -9 jours / Lundi de pentecote +6 jours', NULL), +(getuuid(), 'HORESCA', date(date('$EASTERMONDAY') + interval '50 days' - interval '9 days') , date(date('$EASTERMONDAY') + interval '50 days' - interval '6 days'), '08:00:00'::interval, '12:00:00'::interval, '40:00:00'::interval, '51:00:00'::interval, '03:00:00'::interval, NULL, '11:00:00', NULL, '<15', 'Lundi de pentecote -9 jours / Lundi de pentecote +6 jours', NULL), +(getuuid(), 'HORESCA', date(date('$EASTERMONDAY') + interval '50 days' - interval '9 days') , date(date('$EASTERMONDAY') + interval '50 days' - interval '6 days'), '08:00:00'::interval, '12:00:00'::interval, '40:00:00'::interval, '51:00:00'::interval, '03:00:00'::interval, NULL, '11:00:00', NULL, '>=50', 'Lundi de pentecote -9 jours / Lundi de pentecote +6 jours', NULL); diff --git a/app/bin/setworktimehours.sh b/app/bin/setworktimehours.sh new file mode 100644 index 00000000..e79d32b8 --- /dev/null +++ b/app/bin/setworktimehours.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +CALLDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +# EASTERMONDAY="2022-04-17" +# YEAR=${EASTERMONDAY:0:4} + +# SQL=$(sed -e "s/\$EASTERMONDAY/$EASTERMONDAY/g" -e "s/\$YEAR/$YEAR/g" ${CALLDIR}/sectorworktimes.sql) +# echo ${SQL} +source ${CALLDIR}"/conf.sh" + +# psql -h ${DBLIVEHOST} -U ${DBUSER} ${DBNAME} -c "${SQL}" + +# select id from public.sectorworktimes where startdate between date('2022-01-01') and date('2022-12-31') + +ALLSCHEMA=(`psql -h ${DBLIVEHOST} -U ${DBUSER} -t -A -c "select schema_name from information_schema.schemata where (catalog_name='${DBNAME}' and schema_owner = '${DBUSER}') or (catalog_name='${DBNAME}' and schema_name='public');" ${DBNAME}`) +# #echo ${ALLSCHEMA}; +for schema in "${ALLSCHEMA[@]}" +do + + SECTOR=(`psql -h ${DBLIVEHOST} -U ${DBUSER} -t -A -c "select sector from companies where schemata ='$schema'" ${DBNAME}`); + echo "check schema $schema => ${SECTOR}" + wkUPD="INSERT INTO "$schema".worktimes +(startdate, enddate, defaultdayhours, maxdayhours, defaultweekhours, maxweekhours, maxinterruptionhours, isdefault, id, mindailyrecuperation, maxhourspercents) +select startdate, enddate, defaultdayhours, maxdayhours, defaultweekhours, maxweekhours, maxinterruptionhours, isdefault, id, mindailyrecuperation, maxhourspercents from public.sectorworktime gwk +where sector='"$SECTOR"' and periodtype='".$periodtype."' and (startdate is null or date_part('year',startdate)>=date_part('year',current_date)) +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;"; +done \ No newline at end of file diff --git a/app/bin/setyearlyworktimes.php b/app/bin/setyearlyworktimes.php new file mode 100644 index 00000000..e69de29b diff --git a/app/lib/POT/Company.php b/app/lib/POT/Company.php index 1fd8a25a..b44cf66f 100644 --- a/app/lib/POT/Company.php +++ b/app/lib/POT/Company.php @@ -171,6 +171,8 @@ function getVacancyTypes($schema ){ $this->dbh->queryarray($sql); } + + //TODO: add button for sync to schemas function updateSchemaWorktimes($schema ,$sector ,$periodtype){ @@ -184,4 +186,6 @@ startdate=excluded.startdate, enddate=excluded.enddate, defaultdayhours=excluded } } + + ?> \ No newline at end of file diff --git a/app/lib/POT/Period.php b/app/lib/POT/Period.php index 90086122..0cf23d4c 100644 --- a/app/lib/POT/Period.php +++ b/app/lib/POT/Period.php @@ -107,7 +107,7 @@ public function getStaffPeriods($schema,$id_period,$id_groups=null,$splitted="0" $where = " AND srp.id_reportperiod = '".$id_period."' "; // } if (($id_groups != null) && ($id_groups != '') && (strlen($id_groups) >= 3)){ - error_log("Groups ->" .print_r($id_groups,true)); + //error_log("Groups ->" .print_r($id_groups,true)); $tmpgrp = json_decode($id_groups); $wgroups .= " and sgr.id in ('".implode("','",$tmpgrp)."') "; } @@ -470,12 +470,13 @@ public function updateStaffPeriod($schema,$id_period,$id_staff){ join ".$schema.".reportperiod rp on (rp.id=srp.id_reportperiod) where srp.id_staff='".$id_staff."' order by rp.startdate,rp.enddate) sper ) prp where id='".$id_period."'; "; + $staffprdprev = $this->dbh->query($sqlx); $prevprddata=array("statussuncount" => ""); //print STDERR Dumper($staffprdprev); $sql = "select id from ".$schema.".staffreportperioddays where id_staff='".$id_staff."' and daydate between date(date_trunc('week',date('".$prd["startdate"]."'))) and date(date_trunc('week',date('".$prd["enddate"]."')) + interval '6 days')"; $this->updatePeriodDaySums($schema,$sql); - if ($staffprdprev["prevperiod"] != ''){ + if (isset($staffprdprev) && $staffprdprev != false && ($staffprdprev["prevperiod"] != '')){ $prevsql = "select * from ".$schema.".staffreportperiod where id_reportperiod='".$staffprdprev["prevperiod"]."' and id_staff='".$id_staff."';"; //print STDERR "PrevSQL:".$prevsql."\n==========\n"; $prevprddata = $this->dbh->query($prevsql); @@ -536,7 +537,7 @@ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours ORDER BY weekstart) ws) wsavg order by weekstart DESC LIMIT 1;"; //print STDERR "SQLSun:".$sqlavghours."\n"; $whavg = $this->dbh->query($sqlavghours); - + //error_log(print_r($whavg)); $sql = "update ".$schema.".staffreportperiod rpd set --contracthours=csp.contracthours, workhours=csp.workhours, @@ -553,7 +554,7 @@ sum(CASE WHEN srpd.dayhours IS NULL THEN '00:00:00'::interval ELSE srpd.dayhours $sql .= "suppvacancy44hours=".(($status44count["plusdays"] >= "0")?$status44count["plusdays"]:'null').","; $sql .= "status44hcount=".(($status44count["weeksrest"] == "")?'null':$status44count["weeksrest"]).","; $sql .= "last44date=".(($status44count["maxdate"] == "")?'null':"date('".$status44count["maxdate"]."')").","; - $sql .= "avgtotalweekhours=".(($whavg["avgtotalhours"] == "")?'null':"'".$whavg["avgtotalhours"]."'::interval").","; + $sql .= "avgtotalweekhours=".((!is_null($whavg) || $whavg["avgtotalhours"] == "")?'null':"'".$whavg["avgtotalhours"]."'::interval").","; $sql .= "hoursdiff=csp.diffhours FROM ( select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( diff --git a/app/lib/POT/Staff.php b/app/lib/POT/Staff.php index 7dac35e4..361424ac 100644 --- a/app/lib/POT/Staff.php +++ b/app/lib/POT/Staff.php @@ -150,7 +150,7 @@ $wgroups = ""; $sql = "select ttr.*, st.* ,stg.groupname,COALESCE(st.surname || ' ', '') || COALESCE(st.prename, '') AS staffname,sc.staffstatus from ".$schema.".staff st LEFT JOIN ".$schema.".staffgroups stg ON st.id_staffgroup = stg.id left join (select id_staff, case when min(startdate) <= current_date and (max(enddate) is null or max(enddate) >= current_date) then 'current' - when min(startdate) > current_date then 'futur' when max(enddate) < current_date then 'past' else null end as staffstatus,min(startdate)as startdate,max(enddate) as enddate from ".$schema.".staffcontract group by id_staff) sc on (st.id=sc.id_staff) + when min(startdate) > current_date then 'futur' when max(enddate) < current_date then 'past' else null end as staffstatus,min(startdate)as startdate,max(enddate) as enddate from (select id_staff,startdate,case when enddate is null then current_date else enddate end as enddate from ".$schema.".staffcontract) scc group by id_staff) sc on (st.id=sc.id_staff) cross join (select timetrackertype,case when timetrackertype is not null then true else null end as istimetrackerenabled,periodtypes from public.companies where schemata='".$schema."') ttr where st.isdeleted is null ".$wgroups." order by groupname,st.staffnumber,surname,prename;"; diff --git a/app/lib/POT/User.php b/app/lib/POT/User.php index 6ebca69f..5cb16eb7 100644 --- a/app/lib/POT/User.php +++ b/app/lib/POT/User.php @@ -24,12 +24,11 @@ public function getUserSchemata($id_user,$id_usergroup){ WHERE users.isdeleted IS null and id='".$id_user."') us LEFT JOIN companies cp ON cp.schemata = us.schemaaccess AND cp.isdeleted IS NULL;"; if ($id_usergroup == "admin"){ - $sql = "SELECT distinct(us.schemaaccess),cp.company, - us.schemaaccess AS schemaname, - cp.datasetname - FROM ( SELECT json_array_elements_text(users.schemaaccess) AS schemaaccess - FROM users WHERE users.isdeleted IS null) us - LEFT JOIN companies cp ON cp.schemata = us.schemaaccess AND cp.isdeleted IS NULL;"; + $sql = "SELECT distinct(us.schema_name),case when cp.company is null then 'schema:' || us.schema_name else company end as company , + us.schema_name AS schemaname, + case when datasetname is null then 'schema:' || us.schema_name else datasetname end as datasetname + FROM ( select schema_name from information_schema.schemata where schema_owner != 'postgres' and schema_name != 'public') us + LEFT JOIN companies cp ON cp.schemata = us.schema_name AND cp.isdeleted IS null and cp.company is not null;"; } return $this->dbh->queryarray($sql); } diff --git a/app/lib/composer.json b/app/lib/composer.json index 72a6e8ba..d43013d4 100644 --- a/app/lib/composer.json +++ b/app/lib/composer.json @@ -3,6 +3,7 @@ "mustache/mustache":"2.13.0", "phpmailer/phpmailer":"~6.1", "twig/twig": "^3.3", - "erusev/parsedown": "^1.7" + "erusev/parsedown": "^1.7", + "simshaun/recurr": "^5.0" } } diff --git a/app/lib/composer.lock b/app/lib/composer.lock index 7e75820a..3c92871a 100644 --- a/app/lib/composer.lock +++ b/app/lib/composer.lock @@ -4,8 +4,77 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ccbd0a4e8d1306189eb2313ef1d33313", + "content-hash": "22421590e7cfdd5ed41d559285054b6f", "packages": [ + { + "name": "doctrine/collections", + "version": "1.6.8", + "source": { + "type": "git", + "url": "https://github.com/doctrine/collections.git", + "reference": "1958a744696c6bb3bb0d28db2611dc11610e78af" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/collections/zipball/1958a744696c6bb3bb0d28db2611dc11610e78af", + "reference": "1958a744696c6bb3bb0d28db2611dc11610e78af", + "shasum": "" + }, + "require": { + "php": "^7.1.3 || ^8.0" + }, + "require-dev": { + "doctrine/coding-standard": "^9.0", + "phpstan/phpstan": "^0.12", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.1.5", + "vimeo/psalm": "^4.2.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Common\\Collections\\": "lib/Doctrine/Common/Collections" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.", + "homepage": "https://www.doctrine-project.org/projects/collections.html", + "keywords": [ + "array", + "collections", + "iterators", + "php" + ], + "support": { + "issues": "https://github.com/doctrine/collections/issues", + "source": "https://github.com/doctrine/collections/tree/1.6.8" + }, + "time": "2021-08-10T18:51:53+00:00" + }, { "name": "erusev/parsedown", "version": "1.7.4", @@ -171,6 +240,65 @@ ], "time": "2020-10-09T14:55:58+00:00" }, + { + "name": "simshaun/recurr", + "version": "v5.0.0", + "source": { + "type": "git", + "url": "https://github.com/simshaun/recurr.git", + "reference": "b5aa5b07a595023b67a558b810390dfa7160e3f5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/simshaun/recurr/zipball/b5aa5b07a595023b67a558b810390dfa7160e3f5", + "reference": "b5aa5b07a595023b67a558b810390dfa7160e3f5", + "shasum": "" + }, + "require": { + "doctrine/collections": "~1.6", + "php": "^7.2||^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^8.5.16", + "symfony/yaml": "^5.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Recurr\\": "src/Recurr/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Shaun Simmons", + "email": "shaun@shaun.pub", + "homepage": "https://shaun.pub" + } + ], + "description": "PHP library for working with recurrence rules", + "homepage": "https://github.com/simshaun/recurr", + "keywords": [ + "dates", + "events", + "recurrence", + "recurring", + "rrule" + ], + "support": { + "issues": "https://github.com/simshaun/recurr/issues", + "source": "https://github.com/simshaun/recurr/tree/v5.0.0" + }, + "time": "2021-09-09T03:42:57+00:00" + }, { "name": "symfony/polyfill-ctype", "version": "v1.22.1", diff --git a/app/lib/database.php b/app/lib/database.php index d32c1580..e4ebdc0f 100644 --- a/app/lib/database.php +++ b/app/lib/database.php @@ -29,9 +29,9 @@ class database { public function query($sql){ $result = array(); - if ($this->dbconf["debug"] == 1){ - $this->dblog("QUERY: ".$sql); - } + // if ($this->dbconf["debug"] == 1){ + // $this->dblog("QUERY: ".$sql); + // } try { if ($this->conn){ $sth = $this->conn->prepare($sql); @@ -48,9 +48,9 @@ class database { public function querybykey($key,$sql){ $result = null; $kresult = array(); - if ($this->dbconf["debug"] == 1){ - $this->dblog("QUERYBYKEY: ".$sql); - } + // if ($this->dbconf["debug"] == 1){ + // $this->dblog("QUERYBYKEY: ".$sql); + // } try { if ($this->conn){ $sth = $this->conn->prepare($sql); @@ -70,9 +70,9 @@ class database { public function queryarray($sql){ $result = null; - if ($this->dbconf["debug"] == 1){ - $this->dblog("QUERYARRAY: ".$sql); - } + // if ($this->dbconf["debug"] == 1){ + // $this->dblog("QUERYARRAY: ".$sql); + // } try { if ($this->conn){ $sth = $this->conn->prepare($sql); diff --git a/app/lib/vendor/composer/autoload_psr4.php b/app/lib/vendor/composer/autoload_psr4.php index 45602a37..cf831bea 100644 --- a/app/lib/vendor/composer/autoload_psr4.php +++ b/app/lib/vendor/composer/autoload_psr4.php @@ -9,5 +9,7 @@ return array( 'Twig\\' => array($vendorDir . '/twig/twig/src'), 'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'), 'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'), + 'Recurr\\' => array($vendorDir . '/simshaun/recurr/src/Recurr'), 'PHPMailer\\PHPMailer\\' => array($vendorDir . '/phpmailer/phpmailer/src'), + 'Doctrine\\Common\\Collections\\' => array($vendorDir . '/doctrine/collections/lib/Doctrine/Common/Collections'), ); diff --git a/app/lib/vendor/composer/autoload_static.php b/app/lib/vendor/composer/autoload_static.php index 28a99f70..1bc01e41 100644 --- a/app/lib/vendor/composer/autoload_static.php +++ b/app/lib/vendor/composer/autoload_static.php @@ -21,10 +21,18 @@ class ComposerStaticInit885fbe19dab1b37aa91c383b45da3786 'Symfony\\Polyfill\\Mbstring\\' => 26, 'Symfony\\Polyfill\\Ctype\\' => 23, ), + 'R' => + array ( + 'Recurr\\' => 7, + ), 'P' => array ( 'PHPMailer\\PHPMailer\\' => 20, ), + 'D' => + array ( + 'Doctrine\\Common\\Collections\\' => 28, + ), ); public static $prefixDirsPsr4 = array ( @@ -40,10 +48,18 @@ class ComposerStaticInit885fbe19dab1b37aa91c383b45da3786 array ( 0 => __DIR__ . '/..' . '/symfony/polyfill-ctype', ), + 'Recurr\\' => + array ( + 0 => __DIR__ . '/..' . '/simshaun/recurr/src/Recurr', + ), 'PHPMailer\\PHPMailer\\' => array ( 0 => __DIR__ . '/..' . '/phpmailer/phpmailer/src', ), + 'Doctrine\\Common\\Collections\\' => + array ( + 0 => __DIR__ . '/..' . '/doctrine/collections/lib/Doctrine/Common/Collections', + ), ); public static $prefixesPsr0 = array ( diff --git a/app/lib/vendor/composer/installed.json b/app/lib/vendor/composer/installed.json index 3d60f98d..1f649f02 100644 --- a/app/lib/vendor/composer/installed.json +++ b/app/lib/vendor/composer/installed.json @@ -1,5 +1,77 @@ { "packages": [ + { + "name": "doctrine/collections", + "version": "1.6.8", + "version_normalized": "1.6.8.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/collections.git", + "reference": "1958a744696c6bb3bb0d28db2611dc11610e78af" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/collections/zipball/1958a744696c6bb3bb0d28db2611dc11610e78af", + "reference": "1958a744696c6bb3bb0d28db2611dc11610e78af", + "shasum": "" + }, + "require": { + "php": "^7.1.3 || ^8.0" + }, + "require-dev": { + "doctrine/coding-standard": "^9.0", + "phpstan/phpstan": "^0.12", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.1.5", + "vimeo/psalm": "^4.2.1" + }, + "time": "2021-08-10T18:51:53+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Doctrine\\Common\\Collections\\": "lib/Doctrine/Common/Collections" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.", + "homepage": "https://www.doctrine-project.org/projects/collections.html", + "keywords": [ + "array", + "collections", + "iterators", + "php" + ], + "support": { + "issues": "https://github.com/doctrine/collections/issues", + "source": "https://github.com/doctrine/collections/tree/1.6.8" + }, + "install-path": "../doctrine/collections" + }, { "name": "erusev/parsedown", "version": "1.7.4", @@ -174,6 +246,68 @@ ], "install-path": "../phpmailer/phpmailer" }, + { + "name": "simshaun/recurr", + "version": "v5.0.0", + "version_normalized": "5.0.0.0", + "source": { + "type": "git", + "url": "https://github.com/simshaun/recurr.git", + "reference": "b5aa5b07a595023b67a558b810390dfa7160e3f5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/simshaun/recurr/zipball/b5aa5b07a595023b67a558b810390dfa7160e3f5", + "reference": "b5aa5b07a595023b67a558b810390dfa7160e3f5", + "shasum": "" + }, + "require": { + "doctrine/collections": "~1.6", + "php": "^7.2||^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^8.5.16", + "symfony/yaml": "^5.3" + }, + "time": "2021-09-09T03:42:57+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Recurr\\": "src/Recurr/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Shaun Simmons", + "email": "shaun@shaun.pub", + "homepage": "https://shaun.pub" + } + ], + "description": "PHP library for working with recurrence rules", + "homepage": "https://github.com/simshaun/recurr", + "keywords": [ + "dates", + "events", + "recurrence", + "recurring", + "rrule" + ], + "support": { + "issues": "https://github.com/simshaun/recurr/issues", + "source": "https://github.com/simshaun/recurr/tree/v5.0.0" + }, + "install-path": "../simshaun/recurr" + }, { "name": "symfony/polyfill-ctype", "version": "v1.22.1", diff --git a/app/lib/vendor/composer/installed.php b/app/lib/vendor/composer/installed.php index 90b93fc2..0e7f25c2 100644 --- a/app/lib/vendor/composer/installed.php +++ b/app/lib/vendor/composer/installed.php @@ -5,7 +5,7 @@ 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => '3d955194a6e2e56267fc00f5753a28b571f894c0', + 'reference' => 'a88fcc216dc5125d828c88edd418e569e3134611', 'name' => '__root__', 'dev' => true, ), @@ -16,7 +16,16 @@ 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => '3d955194a6e2e56267fc00f5753a28b571f894c0', + 'reference' => 'a88fcc216dc5125d828c88edd418e569e3134611', + 'dev_requirement' => false, + ), + 'doctrine/collections' => array( + 'pretty_version' => '1.6.8', + 'version' => '1.6.8.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../doctrine/collections', + 'aliases' => array(), + 'reference' => '1958a744696c6bb3bb0d28db2611dc11610e78af', 'dev_requirement' => false, ), 'erusev/parsedown' => array( @@ -46,6 +55,15 @@ 'reference' => '917ab212fa00dc6eacbb26e8bc387ebe40993bc1', 'dev_requirement' => false, ), + 'simshaun/recurr' => array( + 'pretty_version' => 'v5.0.0', + 'version' => '5.0.0.0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../simshaun/recurr', + 'aliases' => array(), + 'reference' => 'b5aa5b07a595023b67a558b810390dfa7160e3f5', + 'dev_requirement' => false, + ), 'symfony/polyfill-ctype' => array( 'pretty_version' => 'v1.22.1', 'version' => '1.22.1.0', diff --git a/app/lib/vendor/doctrine/collections/.doctrine-project.json b/app/lib/vendor/doctrine/collections/.doctrine-project.json new file mode 100644 index 00000000..a0c1a6eb --- /dev/null +++ b/app/lib/vendor/doctrine/collections/.doctrine-project.json @@ -0,0 +1,26 @@ +{ + "active": true, + "name": "Collections", + "slug": "collections", + "docsSlug": "doctrine-collections", + "versions": [ + { + "name": "2.0", + "branchName": "2.0.x", + "slug": "latest", + "upcoming": true + }, + { + "name": "1.7", + "branchName": "1.7.x", + "slug": "1.7", + "upcoming": true + }, + { + "name": "1.6", + "branchName": "1.6.x", + "slug": "1.6", + "current": true + } + ] +} diff --git a/app/lib/vendor/doctrine/collections/CONTRIBUTING.md b/app/lib/vendor/doctrine/collections/CONTRIBUTING.md new file mode 100644 index 00000000..0f3a03b4 --- /dev/null +++ b/app/lib/vendor/doctrine/collections/CONTRIBUTING.md @@ -0,0 +1,54 @@ +# Contribute to Doctrine + +Thank you for contributing to Doctrine! + +Before we can merge your Pull-Request here are some guidelines that you need to follow. +These guidelines exist not to annoy you, but to keep the code base clean, +unified and future proof. + +## We only accept PRs to "master" + +Our branching strategy is "everything to master first", even +bugfixes and we then merge them into the stable branches. You should only +open pull requests against the master branch. Otherwise we cannot accept the PR. + +There is one exception to the rule, when we merged a bug into some stable branches +we do occasionally accept pull requests that merge the same bug fix into earlier +branches. + +## Coding Standard + +We use the [Doctrine Coding Standard](https://github.com/doctrine/coding-standard). + +## Unit-Tests + +Please try to add a test for your pull-request. + +* If you want to contribute new functionality add unit- or functional tests + depending on the scope of the feature. + +You can run the unit-tests by calling ``vendor/bin/phpunit`` from the root of the project. +It will run all the project tests. + +In order to do that, you will need a fresh copy of doctrine/collections, and you +will have to run a composer installation in the project: + +```sh +git clone git@github.com:doctrine/collections.git +cd collections +curl -sS https://getcomposer.org/installer | php -- +./composer.phar install +``` + +## Github Actions + +We automatically run your pull request through Github Actions against supported +PHP versions. If you break the tests, we cannot merge your code, so please make +sure that your code is working before opening up a Pull-Request. + +## Getting merged + +Please allow us time to review your pull requests. We will give our best to review +everything as fast as possible, but cannot always live up to our own expectations. + +Thank you very much again for your contribution! diff --git a/app/lib/vendor/doctrine/collections/LICENSE b/app/lib/vendor/doctrine/collections/LICENSE new file mode 100644 index 00000000..5e781fce --- /dev/null +++ b/app/lib/vendor/doctrine/collections/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2006-2013 Doctrine Project + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/app/lib/vendor/doctrine/collections/README.md b/app/lib/vendor/doctrine/collections/README.md new file mode 100644 index 00000000..5b37bad2 --- /dev/null +++ b/app/lib/vendor/doctrine/collections/README.md @@ -0,0 +1,92 @@ +# Doctrine Collections + +[![Build Status](https://github.com/doctrine/collections/workflows/Continuous%20Integration/badge.svg)](https://github.com/doctrine/collections/actions) +[![Code Coverage](https://codecov.io/gh/doctrine/collections/branch/master/graph/badge.svg)](https://codecov.io/gh/doctrine/collections/branch/master) + +Collections Abstraction library + +## Changelog + +### v1.6.1 + +This release, combined with the release of [`doctrine/collections` `v1.6.1`](https://github.com/doctrine/collections/releases/tag/v1.6.1), +fixes an issue where parsing annotations was not possible +for classes within `doctrine/collections`. + +Specifically, `v1.6.0` introduced Psalm-specific annotations +such as (for example) `@template` and `@template-implements`, +which were both incorrectly recognized as `@template`. + +`@template` has therefore been removed, and instead we use +the prefixed `@psalm-template`, which is no longer parsed +by `doctrine/collections` `v1.6.1` + +Total issues resolved: **1** + +- [186: Use `@psalm-template` annotation to avoid clashes](https://github.com/doctrine/collections/pull/186) thanks to @muglug + +### v1.6.0 + +This release bumps the minimum required PHP version to 7.1.3. + +Following improvements were introduced: + + * `ArrayCollection#filter()` now allows filtering by key, value or both. + * When using the `ClosureExpressionVisitor` over objects with a defined + accessor and property, the accessor is prioritised. + * Updated testing tools and coding standards, autoloading, which also + led to marginal performance improvements + * Introduced generic type docblock declarations from [psalm](https://github.com/vimeo/psalm), + which should allow users to declare `/** @var Collection */` + in their code, and leverage the type propagation deriving from that. + +Total issues resolved: **16** + +- [127: Use PSR-4](https://github.com/doctrine/collections/pull/127) thanks to @Nyholm +- [129: Remove space in method declaration](https://github.com/doctrine/collections/pull/129) thanks to @bounoable +- [130: Update build to add PHPCS and PHPStan](https://github.com/doctrine/collections/pull/130) thanks to @lcobucci +- [131: ClosureExpressionVisitor > Don't duplicate the accessor when the field already starts with it](https://github.com/doctrine/collections/pull/131) thanks to @ruudk +- [139: Apply Doctrine CS 2.1](https://github.com/doctrine/collections/pull/139) thanks to @Majkl578 +- [142: CS 4.0, version composer.lock, merge stages](https://github.com/doctrine/collections/pull/142) thanks to @Majkl578 +- [144: Update to PHPUnit 7](https://github.com/doctrine/collections/pull/144) thanks to @carusogabriel +- [146: Update changelog for v1.4.0 and v1.5.0](https://github.com/doctrine/collections/pull/146) thanks to @GromNaN +- [154: Update index.rst](https://github.com/doctrine/collections/pull/154) thanks to @chraiet +- [158: Extract Selectable method into own documentation section](https://github.com/doctrine/collections/pull/158) thanks to @SenseException +- [160: Update homepage](https://github.com/doctrine/collections/pull/160) thanks to @Majkl578 +- [165: Allow `ArrayCollection#filter()` to filter by key, value or both](https://github.com/doctrine/collections/issues/165) thanks to @0x13a +- [167: Allow `ArrayCollection#filter()` to filter by key and also value](https://github.com/doctrine/collections/pull/167) thanks to @0x13a +- [175: CI: Test against PHP 7.4snapshot instead of nightly (8.0)](https://github.com/doctrine/collections/pull/175) thanks to @Majkl578 +- [177: Generify collections using Psalm](https://github.com/doctrine/collections/pull/177) thanks to @nschoellhorn +- [178: Updated doctrine/coding-standard to 6.0](https://github.com/doctrine/collections/pull/178) thanks to @patrickjahns + +### v1.5.0 + +* [Require PHP 7.1+](https://github.com/doctrine/collections/pull/105) +* [Drop HHVM support](https://github.com/doctrine/collections/pull/118) + +### v1.4.0 + +* [Require PHP 5.6+](https://github.com/doctrine/collections/pull/105) +* [Add `ArrayCollection::createFrom()`](https://github.com/doctrine/collections/pull/91) +* [Support non-camel-case naming](https://github.com/doctrine/collections/pull/57) +* [Comparison `START_WITH`, `END_WITH`](https://github.com/doctrine/collections/pull/78) +* [Comparison `MEMBER_OF`](https://github.com/doctrine/collections/pull/66) +* [Add Contributing guide](https://github.com/doctrine/collections/pull/103) + +### v1.3.0 + +* [Explicit casting of first and max results in criteria API](https://github.com/doctrine/collections/pull/26) +* [Keep keys when using `ArrayCollection#matching()` with sorting](https://github.com/doctrine/collections/pull/49) +* [Made `AbstractLazyCollection#$initialized` protected for extensibility](https://github.com/doctrine/collections/pull/52) + +### v1.2.0 + +* Add a new ``AbstractLazyCollection`` + +### v1.1.0 + +* Deprecated ``Comparison::IS``, because it's only there for SQL semantics. + These are fixed in the ORM instead. +* Add ``Comparison::CONTAINS`` to perform partial string matches: + + $criteria->andWhere($criteria->expr()->contains('property', 'Foo')); diff --git a/app/lib/vendor/doctrine/collections/composer.json b/app/lib/vendor/doctrine/collections/composer.json new file mode 100644 index 00000000..9a6494e7 --- /dev/null +++ b/app/lib/vendor/doctrine/collections/composer.json @@ -0,0 +1,37 @@ +{ + "name": "doctrine/collections", + "type": "library", + "description": "PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.", + "keywords": [ + "php", + "collections", + "array", + "iterators" + ], + "homepage": "https://www.doctrine-project.org/projects/collections.html", + "license": "MIT", + "authors": [ + {"name": "Guilherme Blanco", "email": "guilhermeblanco@gmail.com"}, + {"name": "Roman Borschel", "email": "roman@code-factory.org"}, + {"name": "Benjamin Eberlei", "email": "kontakt@beberlei.de"}, + {"name": "Jonathan Wage", "email": "jonwage@gmail.com"}, + {"name": "Johannes Schmitt", "email": "schmittjoh@gmail.com"} + ], + "require": { + "php": "^7.1.3 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.1.5", + "doctrine/coding-standard": "^9.0", + "phpstan/phpstan": "^0.12", + "vimeo/psalm": "^4.2.1" + }, + "autoload": { + "psr-4": { "Doctrine\\Common\\Collections\\": "lib/Doctrine/Common/Collections" } + }, + "autoload-dev": { + "psr-4": { + "Doctrine\\Tests\\": "tests/Doctrine/Tests" + } + } +} diff --git a/app/lib/vendor/doctrine/collections/docs/en/derived-collections.rst b/app/lib/vendor/doctrine/collections/docs/en/derived-collections.rst new file mode 100644 index 00000000..03d9da5d --- /dev/null +++ b/app/lib/vendor/doctrine/collections/docs/en/derived-collections.rst @@ -0,0 +1,26 @@ +Derived Collections +=================== + +You can create custom collection classes by extending the +``Doctrine\Common\Collections\ArrayCollection`` class. If the +``__construct`` semantics are different from the default ``ArrayCollection`` +you can override the ``createFrom`` method: + +.. code-block:: php + final class DerivedArrayCollection extends ArrayCollection + { + /** @var \stdClass */ + private $foo; + + public function __construct(\stdClass $foo, array $elements = []) + { + $this->foo = $foo; + + parent::__construct($elements); + } + + protected function createFrom(array $elements) : self + { + return new static($this->foo, $elements); + } + } diff --git a/app/lib/vendor/doctrine/collections/docs/en/expression-builder.rst b/app/lib/vendor/doctrine/collections/docs/en/expression-builder.rst new file mode 100644 index 00000000..ad4055b5 --- /dev/null +++ b/app/lib/vendor/doctrine/collections/docs/en/expression-builder.rst @@ -0,0 +1,173 @@ +Expression Builder +================== + +The Expression Builder is a convenient fluent interface for +building expressions to be used with the ``Doctrine\Common\Collections\Criteria`` +class: + +.. code-block:: php + $expressionBuilder = Criteria::expr(); + + $criteria = new Criteria(); + $criteria->where($expressionBuilder->eq('name', 'jwage')); + $criteria->orWhere($expressionBuilder->eq('name', 'romanb')); + + $collection->matching($criteria); + +The ``ExpressionBuilder`` has the following API: + +andX +---- + +.. code-block:: php + $expressionBuilder = Criteria::expr(); + + $expression = $expressionBuilder->andX( + $expressionBuilder->eq('foo', 1), + $expressionBuilder->eq('bar', 1) + ); + + $collection->matching(new Criteria($expression)); + +orX +--- + +.. code-block:: php + $expressionBuilder = Criteria::expr(); + + $expression = $expressionBuilder->orX( + $expressionBuilder->eq('foo', 1), + $expressionBuilder->eq('bar', 1) + ); + + $collection->matching(new Criteria($expression)); + +eq +--- + +.. code-block:: php + $expressionBuilder = Criteria::expr(); + + $expression = $expressionBuilder->eq('foo', 1); + + $collection->matching(new Criteria($expression)); + +gt +--- + +.. code-block:: php + $expressionBuilder = Criteria::expr(); + + $expression = $expressionBuilder->gt('foo', 1); + + $collection->matching(new Criteria($expression)); + +lt +--- + +.. code-block:: php + $expressionBuilder = Criteria::expr(); + + $expression = $expressionBuilder->lt('foo', 1); + + $collection->matching(new Criteria($expression)); + +gte +--- + +.. code-block:: php + $expressionBuilder = Criteria::expr(); + + $expression = $expressionBuilder->gte('foo', 1); + + $collection->matching(new Criteria($expression)); + +lte +--- + +.. code-block:: php + $expressionBuilder = Criteria::expr(); + + $expression = $expressionBuilder->lte('foo', 1); + + $collection->matching(new Criteria($expression)); + +neq +--- + +.. code-block:: php + $expressionBuilder = Criteria::expr(); + + $expression = $expressionBuilder->neq('foo', 1); + + $collection->matching(new Criteria($expression)); + +isNull +------ + +.. code-block:: php + $expressionBuilder = Criteria::expr(); + + $expression = $expressionBuilder->isNull('foo'); + + $collection->matching(new Criteria($expression)); + +in +--- + +.. code-block:: php + $expressionBuilder = Criteria::expr(); + + $expression = $expressionBuilder->in('foo', ['value1', 'value2']); + + $collection->matching(new Criteria($expression)); + +notIn +----- + +.. code-block:: php + $expressionBuilder = Criteria::expr(); + + $expression = $expressionBuilder->notIn('foo', ['value1', 'value2']); + + $collection->matching(new Criteria($expression)); + +contains +-------- + +.. code-block:: php + $expressionBuilder = Criteria::expr(); + + $expression = $expressionBuilder->contains('foo', 'value1'); + + $collection->matching(new Criteria($expression)); + +memberOf +-------- + +.. code-block:: php + $expressionBuilder = Criteria::expr(); + + $expression = $expressionBuilder->memberOf('foo', ['value1', 'value2']); + + $collection->matching(new Criteria($expression)); + +startsWith +---------- + +.. code-block:: php + $expressionBuilder = Criteria::expr(); + + $expression = $expressionBuilder->startsWith('foo', 'hello'); + + $collection->matching(new Criteria($expression)); + +endsWith +-------- + +.. code-block:: php + $expressionBuilder = Criteria::expr(); + + $expression = $expressionBuilder->endsWith('foo', 'world'); + + $collection->matching(new Criteria($expression)); diff --git a/app/lib/vendor/doctrine/collections/docs/en/expressions.rst b/app/lib/vendor/doctrine/collections/docs/en/expressions.rst new file mode 100644 index 00000000..db943b24 --- /dev/null +++ b/app/lib/vendor/doctrine/collections/docs/en/expressions.rst @@ -0,0 +1,102 @@ +Expressions +=========== + +The ``Doctrine\Common\Collections\Expr\Comparison`` class +can be used to create expressions to be used with the +``Doctrine\Common\Collections\Criteria`` class. It has the +following operator constants: + +- ``Comparison::EQ`` +- ``Comparison::NEQ`` +- ``Comparison::LT`` +- ``Comparison::LTE`` +- ``Comparison::GT`` +- ``Comparison::GTE`` +- ``Comparison::IS`` +- ``Comparison::IN`` +- ``Comparison::NIN`` +- ``Comparison::CONTAINS`` +- ``Comparison::MEMBER_OF`` +- ``Comparison::STARTS_WITH`` +- ``Comparison::ENDS_WITH`` + +The ``Doctrine\Common\Collections\Criteria`` class has the following +API to be used with expressions: + +where +----- + +Sets the where expression to evaluate when this Criteria is searched for. + +.. code-block:: php + $expr = new Comparison('key', Comparison::EQ, 'value'); + + $criteria->where($expr); + +andWhere +-------- + +Appends the where expression to evaluate when this Criteria is searched for +using an AND with previous expression. + +.. code-block:: php + $expr = new Comparison('key', Comparison::EQ, 'value'); + + $criteria->andWhere($expr); + +orWhere +------- + +Appends the where expression to evaluate when this Criteria is searched for +using an OR with previous expression. + +.. code-block:: php + $expr1 = new Comparison('key', Comparison::EQ, 'value1'); + $expr2 = new Comparison('key', Comparison::EQ, 'value2'); + + $criteria->where($expr1); + $criteria->orWhere($expr2); + +orderBy +------- + +Sets the ordering of the result of this Criteria. + +.. code-block:: php + $criteria->orderBy(['name' => Criteria::ASC]); + +setFirstResult +-------------- + +Set the number of first result that this Criteria should return. + +.. code-block:: php + $criteria->setFirstResult(0); + +getFirstResult +-------------- + +Gets the current first result option of this Criteria. + +.. code-block:: php + $criteria->setFirstResult(10); + + echo $criteria->getFirstResult(); // 10 + +setMaxResults +------------- + +Sets the max results that this Criteria should return. + +.. code-block:: php + $criteria->setMaxResults(20); + +getMaxResults +------------- + +Gets the current max results option of this Criteria. + +.. code-block:: php + $criteria->setMaxResults(20); + + echo $criteria->getMaxResults(); // 20 diff --git a/app/lib/vendor/doctrine/collections/docs/en/index.rst b/app/lib/vendor/doctrine/collections/docs/en/index.rst new file mode 100644 index 00000000..936f9efa --- /dev/null +++ b/app/lib/vendor/doctrine/collections/docs/en/index.rst @@ -0,0 +1,328 @@ +Introduction +============ + +Doctrine Collections is a library that contains classes for working with +arrays of data. Here is an example using the simple +``Doctrine\Common\Collections\ArrayCollection`` class: + +.. code-block:: php + filter(function($element) { + return $element > 1; + }); // [2, 3] + +Collection Methods +================== + +Doctrine Collections provides an interface named ``Doctrine\Common\Collections\Collection`` +that resembles the nature of a regular PHP array. That is, +it is essentially an **ordered map** that can also be used +like a list. + +A Collection has an internal iterator just like a PHP array. In addition, +a Collection can be iterated with external iterators, which is preferable. +To use an external iterator simply use the foreach language construct to +iterate over the collection, which calls ``getIterator()`` internally, or +explicitly retrieve an iterator though ``getIterator()`` which can then be +used to iterate over the collection. You can not rely on the internal iterator +of the collection being at a certain position unless you explicitly positioned it before. + +The methods available on the interface are: + +add +--- + +Adds an element at the end of the collection. + +.. code-block:: php + $collection->add('test'); + +clear +----- + +Clears the collection, removing all elements. + +.. code-block:: php + $collection->clear(); + +contains +-------- + +Checks whether an element is contained in the collection. This is an O(n) operation, where n is the size of the collection. + +.. code-block:: php + $collection = new Collection(['test']); + + $contains = $collection->contains('test'); // true + +containsKey +----------- + +Checks whether the collection contains an element with the specified key/index. + +.. code-block:: php + $collection = new Collection(['test' => true]); + + $contains = $collection->containsKey('test'); // true + +current +------- + +Gets the element of the collection at the current iterator position. + +.. code-block:: php + $collection = new Collection(['first', 'second', 'third']); + + $current = $collection->current(); // first + +get +--- + +Gets the element at the specified key/index. + +.. code-block:: php + $collection = new Collection([ + 'key' => 'value', + ]); + + $value = $collection->get('key'); // value + +getKeys +------- + +Gets all keys/indices of the collection. + +.. code-block:: php + $collection = new Collection(['a', 'b', 'c']); + + $keys = $collection->getKeys(); // [0, 1, 2] + +getValues +--------- + +Gets all values of the collection. + +.. code-block:: php + $collection = new Collection([ + 'key1' => 'value1', + 'key2' => 'value2', + 'key3' => 'value3', + ]); + + $values = $collection->getValues(); // ['value1', 'value2', 'value3'] + +isEmpty +------- + +Checks whether the collection is empty (contains no elements). + +.. code-block:: php + $collection = new Collection(['a', 'b', 'c']); + + $isEmpty = $collection->isEmpty(); // false + +first +----- + +Sets the internal iterator to the first element in the collection and returns this element. + +.. code-block:: php + $collection = new Collection(['first', 'second', 'third']); + + $first = $collection->first(); // first + +exists +------ + +Tests for the existence of an element that satisfies the given predicate. + +.. code-block:: php + $collection = new Collection(['first', 'second', 'third']); + + $exists = $collection->exists(function($key, $value) { + return $value === 'first'; + }); // true + +filter +------ + +Returns all the elements of this collection for which your callback function returns `true`. +The order and keys of the elements are preserved. + +.. code-block:: php + $collection = new ArrayCollection([1, 2, 3]); + + $filteredCollection = $collection->filter(function($element) { + return $element > 1; + }); // [2, 3] + +forAll +------ + +Tests whether the given predicate holds for all elements of this collection. + +.. code-block:: php + $collection = new ArrayCollection([1, 2, 3]); + + $forAll = $collection->forAll(function($key, $value) { + return $value > 1; + }); // false + +indexOf +------- + +Gets the index/key of a given element. The comparison of two elements is strict, that means not only the value but also the type must match. For objects this means reference equality. + +.. code-block:: php + $collection = new ArrayCollection([1, 2, 3]); + + $indexOf = $collection->indexOf(3); // 2 + +key +--- + +Gets the key/index of the element at the current iterator position. + +.. code-block:: php + $collection = new ArrayCollection([1, 2, 3]); + + $collection->next(); + + $key = $collection->key(); // 1 + +last +---- + +Sets the internal iterator to the last element in the collection and returns this element. + +.. code-block:: php + $collection = new ArrayCollection([1, 2, 3]); + + $last = $collection->last(); // 3 + +map +--- + +Applies the given function to each element in the collection and returns a new collection with the elements returned by the function. + +.. code-block:: php + $collection = new ArrayCollection([1, 2, 3]); + + $mappedCollection = $collection->map(function($value) { + return $value + 1; + }); // [2, 3, 4] + +next +---- + +Moves the internal iterator position to the next element and returns this element. + +.. code-block:: php + $collection = new ArrayCollection([1, 2, 3]); + + $next = $collection->next(); // 2 + +partition +--------- + +Partitions this collection in two collections according to a predicate. Keys are preserved in the resulting collections. + +.. code-block:: php + $collection = new ArrayCollection([1, 2, 3]); + + $mappedCollection = $collection->partition(function($key, $value) { + return $value > 1 + }); // [[2, 3], [1]] + +remove +------ + +Removes the element at the specified index from the collection. + +.. code-block:: php + $collection = new ArrayCollection([1, 2, 3]); + + $collection->remove(0); // [2, 3] + +removeElement +------------- + +Removes the specified element from the collection, if it is found. + +.. code-block:: php + $collection = new ArrayCollection([1, 2, 3]); + + $collection->removeElement(3); // [1, 2] + +set +--- + +Sets an element in the collection at the specified key/index. + +.. code-block:: php + $collection = new ArrayCollection(); + + $collection->set('name', 'jwage'); + +slice +----- + +Extracts a slice of $length elements starting at position $offset from the Collection. If $length is null it returns all elements from $offset to the end of the Collection. Keys have to be preserved by this method. Calling this method will only return the selected slice and NOT change the elements contained in the collection slice is called on. + +.. code-block:: php + $collection = new ArrayCollection([0, 1, 2, 3, 4, 5]); + + $slice = $collection->slice(1, 2); // [1, 2] + +toArray +------- + +Gets a native PHP array representation of the collection. + +.. code-block:: php + $collection = new ArrayCollection([0, 1, 2, 3, 4, 5]); + + $array = $collection->toArray(); // [0, 1, 2, 3, 4, 5] + +Selectable Methods +================== + +Some Doctrine Collections, like ``Doctrine\Common\Collections\ArrayCollection``, +implement an interface named ``Doctrine\Common\Collections\Selectable`` +that offers the usage of a powerful expressions API, where conditions +can be applied to a collection to get a result with matching elements +only. + +matching +-------- + +Selects all elements from a selectable that match the expression and +returns a new collection containing these elements. + +.. code-block:: php + use Doctrine\Common\Collections\Criteria; + use Doctrine\Common\Collections\Expr\Comparison; + + $collection = new ArrayCollection([ + [ + 'name' => 'jwage', + ], + [ + 'name' => 'romanb', + ], + ]); + + $expr = new Comparison('name', '=', 'jwage'); + + $criteria = new Criteria(); + + $criteria->where($expr); + + $matched = $collection->matching($criteria); // ['jwage'] + +You can read more about expressions :ref:`here `. diff --git a/app/lib/vendor/doctrine/collections/docs/en/lazy-collections.rst b/app/lib/vendor/doctrine/collections/docs/en/lazy-collections.rst new file mode 100644 index 00000000..b9cafb60 --- /dev/null +++ b/app/lib/vendor/doctrine/collections/docs/en/lazy-collections.rst @@ -0,0 +1,26 @@ +Lazy Collections +================ + +To create a lazy collection you can extend the +``Doctrine\Common\Collections\AbstractLazyCollection`` class +and define the ``doInitialize`` method. Here is an example where +we lazily query the database for a collection of user records: + +.. code-block:: php + use Doctrine\DBAL\Connection; + + class UsersLazyCollection extends AbstractLazyCollection + { + /** @var Connection */ + private $connection; + + public function __construct(Connection $connection) + { + $this->connection = $connection; + } + + protected function doInitialize() : void + { + $this->collection = $this->connection->fetchAll('SELECT * FROM users'); + } + } diff --git a/app/lib/vendor/doctrine/collections/docs/en/sidebar.rst b/app/lib/vendor/doctrine/collections/docs/en/sidebar.rst new file mode 100644 index 00000000..69279a0b --- /dev/null +++ b/app/lib/vendor/doctrine/collections/docs/en/sidebar.rst @@ -0,0 +1,8 @@ +.. toctree:: + :depth: 3 + + index + expressions + expression-builder + derived-collections + lazy-collections diff --git a/app/lib/vendor/doctrine/collections/lib/Doctrine/Common/Collections/AbstractLazyCollection.php b/app/lib/vendor/doctrine/collections/lib/Doctrine/Common/Collections/AbstractLazyCollection.php new file mode 100644 index 00000000..b7b84c69 --- /dev/null +++ b/app/lib/vendor/doctrine/collections/lib/Doctrine/Common/Collections/AbstractLazyCollection.php @@ -0,0 +1,385 @@ + + */ +abstract class AbstractLazyCollection implements Collection +{ + /** + * The backed collection to use + * + * @psalm-var Collection + * @var Collection + */ + protected $collection; + + /** @var bool */ + protected $initialized = false; + + /** + * {@inheritDoc} + * + * @return int + */ + #[ReturnTypeWillChange] + public function count() + { + $this->initialize(); + + return $this->collection->count(); + } + + /** + * {@inheritDoc} + */ + public function add($element) + { + $this->initialize(); + + return $this->collection->add($element); + } + + /** + * {@inheritDoc} + */ + public function clear() + { + $this->initialize(); + $this->collection->clear(); + } + + /** + * {@inheritDoc} + */ + public function contains($element) + { + $this->initialize(); + + return $this->collection->contains($element); + } + + /** + * {@inheritDoc} + */ + public function isEmpty() + { + $this->initialize(); + + return $this->collection->isEmpty(); + } + + /** + * {@inheritDoc} + */ + public function remove($key) + { + $this->initialize(); + + return $this->collection->remove($key); + } + + /** + * {@inheritDoc} + */ + public function removeElement($element) + { + $this->initialize(); + + return $this->collection->removeElement($element); + } + + /** + * {@inheritDoc} + */ + public function containsKey($key) + { + $this->initialize(); + + return $this->collection->containsKey($key); + } + + /** + * {@inheritDoc} + */ + public function get($key) + { + $this->initialize(); + + return $this->collection->get($key); + } + + /** + * {@inheritDoc} + */ + public function getKeys() + { + $this->initialize(); + + return $this->collection->getKeys(); + } + + /** + * {@inheritDoc} + */ + public function getValues() + { + $this->initialize(); + + return $this->collection->getValues(); + } + + /** + * {@inheritDoc} + */ + public function set($key, $value) + { + $this->initialize(); + $this->collection->set($key, $value); + } + + /** + * {@inheritDoc} + */ + public function toArray() + { + $this->initialize(); + + return $this->collection->toArray(); + } + + /** + * {@inheritDoc} + */ + public function first() + { + $this->initialize(); + + return $this->collection->first(); + } + + /** + * {@inheritDoc} + */ + public function last() + { + $this->initialize(); + + return $this->collection->last(); + } + + /** + * {@inheritDoc} + */ + public function key() + { + $this->initialize(); + + return $this->collection->key(); + } + + /** + * {@inheritDoc} + */ + public function current() + { + $this->initialize(); + + return $this->collection->current(); + } + + /** + * {@inheritDoc} + */ + public function next() + { + $this->initialize(); + + return $this->collection->next(); + } + + /** + * {@inheritDoc} + */ + public function exists(Closure $p) + { + $this->initialize(); + + return $this->collection->exists($p); + } + + /** + * {@inheritDoc} + */ + public function filter(Closure $p) + { + $this->initialize(); + + return $this->collection->filter($p); + } + + /** + * {@inheritDoc} + */ + public function forAll(Closure $p) + { + $this->initialize(); + + return $this->collection->forAll($p); + } + + /** + * {@inheritDoc} + */ + public function map(Closure $func) + { + $this->initialize(); + + return $this->collection->map($func); + } + + /** + * {@inheritDoc} + */ + public function partition(Closure $p) + { + $this->initialize(); + + return $this->collection->partition($p); + } + + /** + * {@inheritDoc} + */ + public function indexOf($element) + { + $this->initialize(); + + return $this->collection->indexOf($element); + } + + /** + * {@inheritDoc} + */ + public function slice($offset, $length = null) + { + $this->initialize(); + + return $this->collection->slice($offset, $length); + } + + /** + * {@inheritDoc} + * + * @return Traversable + * @psalm-return Traversable + */ + #[ReturnTypeWillChange] + public function getIterator() + { + $this->initialize(); + + return $this->collection->getIterator(); + } + + /** + * {@inheritDoc} + * + * @psalm-param TKey $offset + * + * @return bool + */ + #[ReturnTypeWillChange] + public function offsetExists($offset) + { + $this->initialize(); + + return $this->collection->offsetExists($offset); + } + + /** + * {@inheritDoc} + * + * @param int|string $offset + * @psalm-param TKey $offset + * + * @return mixed + */ + #[ReturnTypeWillChange] + public function offsetGet($offset) + { + $this->initialize(); + + return $this->collection->offsetGet($offset); + } + + /** + * {@inheritDoc} + * + * @param mixed $value + * @psalm-param TKey $offset + * + * @return void + */ + #[ReturnTypeWillChange] + public function offsetSet($offset, $value) + { + $this->initialize(); + $this->collection->offsetSet($offset, $value); + } + + /** + * {@inheritDoc} + * + * @psalm-param TKey $offset + * + * @return void + */ + #[ReturnTypeWillChange] + public function offsetUnset($offset) + { + $this->initialize(); + $this->collection->offsetUnset($offset); + } + + /** + * Is the lazy collection already initialized? + * + * @return bool + */ + public function isInitialized() + { + return $this->initialized; + } + + /** + * Initialize the collection + * + * @return void + */ + protected function initialize() + { + if ($this->initialized) { + return; + } + + $this->doInitialize(); + $this->initialized = true; + } + + /** + * Do the initialization logic + * + * @return void + */ + abstract protected function doInitialize(); +} diff --git a/app/lib/vendor/doctrine/collections/lib/Doctrine/Common/Collections/ArrayCollection.php b/app/lib/vendor/doctrine/collections/lib/Doctrine/Common/Collections/ArrayCollection.php new file mode 100644 index 00000000..df04f984 --- /dev/null +++ b/app/lib/vendor/doctrine/collections/lib/Doctrine/Common/Collections/ArrayCollection.php @@ -0,0 +1,463 @@ + + * @template-implements Selectable + * @psalm-consistent-constructor + */ +class ArrayCollection implements Collection, Selectable +{ + /** + * An array containing the entries of this collection. + * + * @psalm-var array + * @var mixed[] + */ + private $elements; + + /** + * Initializes a new ArrayCollection. + * + * @param array $elements + * @psalm-param array $elements + */ + public function __construct(array $elements = []) + { + $this->elements = $elements; + } + + /** + * {@inheritDoc} + */ + public function toArray() + { + return $this->elements; + } + + /** + * {@inheritDoc} + */ + public function first() + { + return reset($this->elements); + } + + /** + * Creates a new instance from the specified elements. + * + * This method is provided for derived classes to specify how a new + * instance should be created when constructor semantics have changed. + * + * @param array $elements Elements. + * @psalm-param array $elements + * + * @return static + * @psalm-return static + * + * @psalm-template K of array-key + * @psalm-template V + */ + protected function createFrom(array $elements) + { + return new static($elements); + } + + /** + * {@inheritDoc} + */ + public function last() + { + return end($this->elements); + } + + /** + * {@inheritDoc} + */ + public function key() + { + return key($this->elements); + } + + /** + * {@inheritDoc} + */ + public function next() + { + return next($this->elements); + } + + /** + * {@inheritDoc} + */ + public function current() + { + return current($this->elements); + } + + /** + * {@inheritDoc} + */ + public function remove($key) + { + if (! isset($this->elements[$key]) && ! array_key_exists($key, $this->elements)) { + return null; + } + + $removed = $this->elements[$key]; + unset($this->elements[$key]); + + return $removed; + } + + /** + * {@inheritDoc} + */ + public function removeElement($element) + { + $key = array_search($element, $this->elements, true); + + if ($key === false) { + return false; + } + + unset($this->elements[$key]); + + return true; + } + + /** + * Required by interface ArrayAccess. + * + * {@inheritDoc} + * + * @psalm-param TKey $offset + * + * @return bool + */ + #[ReturnTypeWillChange] + public function offsetExists($offset) + { + return $this->containsKey($offset); + } + + /** + * Required by interface ArrayAccess. + * + * {@inheritDoc} + * + * @psalm-param TKey $offset + * + * @return mixed + */ + #[ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->get($offset); + } + + /** + * Required by interface ArrayAccess. + * + * {@inheritDoc} + * + * @return void + */ + #[ReturnTypeWillChange] + public function offsetSet($offset, $value) + { + if (! isset($offset)) { + $this->add($value); + + return; + } + + $this->set($offset, $value); + } + + /** + * Required by interface ArrayAccess. + * + * {@inheritDoc} + * + * @psalm-param TKey $offset + * + * @return void + */ + #[ReturnTypeWillChange] + public function offsetUnset($offset) + { + $this->remove($offset); + } + + /** + * {@inheritDoc} + */ + public function containsKey($key) + { + return isset($this->elements[$key]) || array_key_exists($key, $this->elements); + } + + /** + * {@inheritDoc} + */ + public function contains($element) + { + return in_array($element, $this->elements, true); + } + + /** + * {@inheritDoc} + */ + public function exists(Closure $p) + { + foreach ($this->elements as $key => $element) { + if ($p($key, $element)) { + return true; + } + } + + return false; + } + + /** + * {@inheritDoc} + */ + public function indexOf($element) + { + return array_search($element, $this->elements, true); + } + + /** + * {@inheritDoc} + */ + public function get($key) + { + return $this->elements[$key] ?? null; + } + + /** + * {@inheritDoc} + */ + public function getKeys() + { + return array_keys($this->elements); + } + + /** + * {@inheritDoc} + */ + public function getValues() + { + return array_values($this->elements); + } + + /** + * {@inheritDoc} + * + * @return int + */ + #[ReturnTypeWillChange] + public function count() + { + return count($this->elements); + } + + /** + * {@inheritDoc} + */ + public function set($key, $value) + { + $this->elements[$key] = $value; + } + + /** + * {@inheritDoc} + * + * @psalm-suppress InvalidPropertyAssignmentValue + * + * This breaks assumptions about the template type, but it would + * be a backwards-incompatible change to remove this method + */ + public function add($element) + { + $this->elements[] = $element; + + return true; + } + + /** + * {@inheritDoc} + */ + public function isEmpty() + { + return empty($this->elements); + } + + /** + * {@inheritDoc} + * + * @return Traversable + * @psalm-return Traversable + */ + #[ReturnTypeWillChange] + public function getIterator() + { + return new ArrayIterator($this->elements); + } + + /** + * {@inheritDoc} + * + * @psalm-param Closure(T=):U $func + * + * @return static + * @psalm-return static + * + * @psalm-template U + */ + public function map(Closure $func) + { + return $this->createFrom(array_map($func, $this->elements)); + } + + /** + * {@inheritDoc} + * + * @return static + * @psalm-return static + */ + public function filter(Closure $p) + { + return $this->createFrom(array_filter($this->elements, $p, ARRAY_FILTER_USE_BOTH)); + } + + /** + * {@inheritDoc} + */ + public function forAll(Closure $p) + { + foreach ($this->elements as $key => $element) { + if (! $p($key, $element)) { + return false; + } + } + + return true; + } + + /** + * {@inheritDoc} + */ + public function partition(Closure $p) + { + $matches = $noMatches = []; + + foreach ($this->elements as $key => $element) { + if ($p($key, $element)) { + $matches[$key] = $element; + } else { + $noMatches[$key] = $element; + } + } + + return [$this->createFrom($matches), $this->createFrom($noMatches)]; + } + + /** + * Returns a string representation of this object. + * + * @return string + */ + public function __toString() + { + return self::class . '@' . spl_object_hash($this); + } + + /** + * {@inheritDoc} + */ + public function clear() + { + $this->elements = []; + } + + /** + * {@inheritDoc} + */ + public function slice($offset, $length = null) + { + return array_slice($this->elements, $offset, $length, true); + } + + /** + * {@inheritDoc} + */ + public function matching(Criteria $criteria) + { + $expr = $criteria->getWhereExpression(); + $filtered = $this->elements; + + if ($expr) { + $visitor = new ClosureExpressionVisitor(); + $filter = $visitor->dispatch($expr); + $filtered = array_filter($filtered, $filter); + } + + $orderings = $criteria->getOrderings(); + + if ($orderings) { + $next = null; + foreach (array_reverse($orderings) as $field => $ordering) { + $next = ClosureExpressionVisitor::sortByField($field, $ordering === Criteria::DESC ? -1 : 1, $next); + } + + uasort($filtered, $next); + } + + $offset = $criteria->getFirstResult(); + $length = $criteria->getMaxResults(); + + if ($offset || $length) { + $filtered = array_slice($filtered, (int) $offset, $length); + } + + return $this->createFrom($filtered); + } +} diff --git a/app/lib/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Collection.php b/app/lib/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Collection.php new file mode 100644 index 00000000..bba3d686 --- /dev/null +++ b/app/lib/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Collection.php @@ -0,0 +1,276 @@ +ordered map that can also be used + * like a list. + * + * A Collection has an internal iterator just like a PHP array. In addition, + * a Collection can be iterated with external iterators, which is preferable. + * To use an external iterator simply use the foreach language construct to + * iterate over the collection (which calls {@link getIterator()} internally) or + * explicitly retrieve an iterator though {@link getIterator()} which can then be + * used to iterate over the collection. + * You can not rely on the internal iterator of the collection being at a certain + * position unless you explicitly positioned it before. Prefer iteration with + * external iterators. + * + * @psalm-template TKey of array-key + * @psalm-template T + * @template-extends IteratorAggregate + * @template-extends ArrayAccess + */ +interface Collection extends Countable, IteratorAggregate, ArrayAccess +{ + /** + * Adds an element at the end of the collection. + * + * @param mixed $element The element to add. + * @psalm-param T $element + * + * @return true Always TRUE. + */ + public function add($element); + + /** + * Clears the collection, removing all elements. + * + * @return void + */ + public function clear(); + + /** + * Checks whether an element is contained in the collection. + * This is an O(n) operation, where n is the size of the collection. + * + * @param mixed $element The element to search for. + * @psalm-param T $element + * + * @return bool TRUE if the collection contains the element, FALSE otherwise. + */ + public function contains($element); + + /** + * Checks whether the collection is empty (contains no elements). + * + * @return bool TRUE if the collection is empty, FALSE otherwise. + */ + public function isEmpty(); + + /** + * Removes the element at the specified index from the collection. + * + * @param string|int $key The key/index of the element to remove. + * @psalm-param TKey $key + * + * @return mixed The removed element or NULL, if the collection did not contain the element. + * @psalm-return T|null + */ + public function remove($key); + + /** + * Removes the specified element from the collection, if it is found. + * + * @param mixed $element The element to remove. + * @psalm-param T $element + * + * @return bool TRUE if this collection contained the specified element, FALSE otherwise. + */ + public function removeElement($element); + + /** + * Checks whether the collection contains an element with the specified key/index. + * + * @param string|int $key The key/index to check for. + * @psalm-param TKey $key + * + * @return bool TRUE if the collection contains an element with the specified key/index, + * FALSE otherwise. + */ + public function containsKey($key); + + /** + * Gets the element at the specified key/index. + * + * @param string|int $key The key/index of the element to retrieve. + * @psalm-param TKey $key + * + * @return mixed + * @psalm-return T|null + */ + public function get($key); + + /** + * Gets all keys/indices of the collection. + * + * @return int[]|string[] The keys/indices of the collection, in the order of the corresponding + * elements in the collection. + * @psalm-return TKey[] + */ + public function getKeys(); + + /** + * Gets all values of the collection. + * + * @return mixed[] The values of all elements in the collection, in the + * order they appear in the collection. + * @psalm-return T[] + */ + public function getValues(); + + /** + * Sets an element in the collection at the specified key/index. + * + * @param string|int $key The key/index of the element to set. + * @param mixed $value The element to set. + * @psalm-param TKey $key + * @psalm-param T $value + * + * @return void + */ + public function set($key, $value); + + /** + * Gets a native PHP array representation of the collection. + * + * @return mixed[] + * @psalm-return array + */ + public function toArray(); + + /** + * Sets the internal iterator to the first element in the collection and returns this element. + * + * @return mixed + * @psalm-return T|false + */ + public function first(); + + /** + * Sets the internal iterator to the last element in the collection and returns this element. + * + * @return mixed + * @psalm-return T|false + */ + public function last(); + + /** + * Gets the key/index of the element at the current iterator position. + * + * @return int|string|null + * @psalm-return TKey|null + */ + public function key(); + + /** + * Gets the element of the collection at the current iterator position. + * + * @return mixed + * @psalm-return T|false + */ + public function current(); + + /** + * Moves the internal iterator position to the next element and returns this element. + * + * @return mixed + * @psalm-return T|false + */ + public function next(); + + /** + * Tests for the existence of an element that satisfies the given predicate. + * + * @param Closure $p The predicate. + * @psalm-param Closure(TKey=, T=):bool $p + * + * @return bool TRUE if the predicate is TRUE for at least one element, FALSE otherwise. + */ + public function exists(Closure $p); + + /** + * Returns all the elements of this collection that satisfy the predicate p. + * The order of the elements is preserved. + * + * @param Closure $p The predicate used for filtering. + * @psalm-param Closure(T=):bool $p + * + * @return Collection A collection with the results of the filter operation. + * @psalm-return Collection + */ + public function filter(Closure $p); + + /** + * Tests whether the given predicate p holds for all elements of this collection. + * + * @param Closure $p The predicate. + * @psalm-param Closure(TKey=, T=):bool $p + * + * @return bool TRUE, if the predicate yields TRUE for all elements, FALSE otherwise. + */ + public function forAll(Closure $p); + + /** + * Applies the given function to each element in the collection and returns + * a new collection with the elements returned by the function. + * + * @psalm-param Closure(T=):U $func + * + * @return Collection + * @psalm-return Collection + * + * @psalm-template U + */ + public function map(Closure $func); + + /** + * Partitions this collection in two collections according to a predicate. + * Keys are preserved in the resulting collections. + * + * @param Closure $p The predicate on which to partition. + * @psalm-param Closure(TKey=, T=):bool $p + * + * @return Collection An array with two elements. The first element contains the collection + * of elements where the predicate returned TRUE, the second element + * contains the collection of elements where the predicate returned FALSE. + * @psalm-return array{0: Collection, 1: Collection} + */ + public function partition(Closure $p); + + /** + * Gets the index/key of a given element. The comparison of two elements is strict, + * that means not only the value but also the type must match. + * For objects this means reference equality. + * + * @param mixed $element The element to search for. + * @psalm-param T $element + * + * @return int|string|bool The key/index of the element or FALSE if the element was not found. + * @psalm-return TKey|false + */ + public function indexOf($element); + + /** + * Extracts a slice of $length elements starting at position $offset from the Collection. + * + * If $length is null it returns all elements from $offset to the end of the Collection. + * Keys have to be preserved by this method. Calling this method will only return the + * selected slice and NOT change the elements contained in the collection slice is called on. + * + * @param int $offset The offset to start from. + * @param int|null $length The maximum number of elements to return, or null for no limit. + * + * @return mixed[] + * @psalm-return array + */ + public function slice($offset, $length = null); +} diff --git a/app/lib/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Criteria.php b/app/lib/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Criteria.php new file mode 100644 index 00000000..9027e070 --- /dev/null +++ b/app/lib/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Criteria.php @@ -0,0 +1,225 @@ +expression = $expression; + + $this->setFirstResult($firstResult); + $this->setMaxResults($maxResults); + + if ($orderings === null) { + return; + } + + $this->orderBy($orderings); + } + + /** + * Sets the where expression to evaluate when this Criteria is searched for. + * + * @return Criteria + */ + public function where(Expression $expression) + { + $this->expression = $expression; + + return $this; + } + + /** + * Appends the where expression to evaluate when this Criteria is searched for + * using an AND with previous expression. + * + * @return Criteria + */ + public function andWhere(Expression $expression) + { + if ($this->expression === null) { + return $this->where($expression); + } + + $this->expression = new CompositeExpression( + CompositeExpression::TYPE_AND, + [$this->expression, $expression] + ); + + return $this; + } + + /** + * Appends the where expression to evaluate when this Criteria is searched for + * using an OR with previous expression. + * + * @return Criteria + */ + public function orWhere(Expression $expression) + { + if ($this->expression === null) { + return $this->where($expression); + } + + $this->expression = new CompositeExpression( + CompositeExpression::TYPE_OR, + [$this->expression, $expression] + ); + + return $this; + } + + /** + * Gets the expression attached to this Criteria. + * + * @return Expression|null + */ + public function getWhereExpression() + { + return $this->expression; + } + + /** + * Gets the current orderings of this Criteria. + * + * @return string[] + */ + public function getOrderings() + { + return $this->orderings; + } + + /** + * Sets the ordering of the result of this Criteria. + * + * Keys are field and values are the order, being either ASC or DESC. + * + * @see Criteria::ASC + * @see Criteria::DESC + * + * @param string[] $orderings + * + * @return Criteria + */ + public function orderBy(array $orderings) + { + $this->orderings = array_map( + static function (string $ordering): string { + return strtoupper($ordering) === Criteria::ASC ? Criteria::ASC : Criteria::DESC; + }, + $orderings + ); + + return $this; + } + + /** + * Gets the current first result option of this Criteria. + * + * @return int|null + */ + public function getFirstResult() + { + return $this->firstResult; + } + + /** + * Set the number of first result that this Criteria should return. + * + * @param int|null $firstResult The value to set. + * + * @return Criteria + */ + public function setFirstResult($firstResult) + { + $this->firstResult = $firstResult; + + return $this; + } + + /** + * Gets maxResults. + * + * @return int|null + */ + public function getMaxResults() + { + return $this->maxResults; + } + + /** + * Sets maxResults. + * + * @param int|null $maxResults The value to set. + * + * @return Criteria + */ + public function setMaxResults($maxResults) + { + $this->maxResults = $maxResults; + + return $this; + } +} diff --git a/app/lib/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/ClosureExpressionVisitor.php b/app/lib/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/ClosureExpressionVisitor.php new file mode 100644 index 00000000..b15ef7a8 --- /dev/null +++ b/app/lib/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/ClosureExpressionVisitor.php @@ -0,0 +1,265 @@ +$accessor(); + } + } + + if (preg_match('/^is[A-Z]+/', $field) === 1 && method_exists($object, $field)) { + return $object->$field(); + } + + // __call should be triggered for get. + $accessor = $accessors[0] . $field; + + if (method_exists($object, '__call')) { + return $object->$accessor(); + } + + if ($object instanceof ArrayAccess) { + return $object[$field]; + } + + if (isset($object->$field)) { + return $object->$field; + } + + // camelcase field name to support different variable naming conventions + $ccField = preg_replace_callback('/_(.?)/', static function ($matches) { + return strtoupper($matches[1]); + }, $field); + + foreach ($accessors as $accessor) { + $accessor .= $ccField; + + if (method_exists($object, $accessor)) { + return $object->$accessor(); + } + } + + return $object->$field; + } + + /** + * Helper for sorting arrays of objects based on multiple fields + orientations. + * + * @param string $name + * @param int $orientation + * + * @return Closure + */ + public static function sortByField($name, $orientation = 1, ?Closure $next = null) + { + if (! $next) { + $next = static function (): int { + return 0; + }; + } + + return static function ($a, $b) use ($name, $next, $orientation): int { + $aValue = ClosureExpressionVisitor::getObjectFieldValue($a, $name); + + $bValue = ClosureExpressionVisitor::getObjectFieldValue($b, $name); + + if ($aValue === $bValue) { + return $next($a, $b); + } + + return ($aValue > $bValue ? 1 : -1) * $orientation; + }; + } + + /** + * {@inheritDoc} + */ + public function walkComparison(Comparison $comparison) + { + $field = $comparison->getField(); + $value = $comparison->getValue()->getValue(); // shortcut for walkValue() + + switch ($comparison->getOperator()) { + case Comparison::EQ: + return static function ($object) use ($field, $value): bool { + return ClosureExpressionVisitor::getObjectFieldValue($object, $field) === $value; + }; + + case Comparison::NEQ: + return static function ($object) use ($field, $value): bool { + return ClosureExpressionVisitor::getObjectFieldValue($object, $field) !== $value; + }; + + case Comparison::LT: + return static function ($object) use ($field, $value): bool { + return ClosureExpressionVisitor::getObjectFieldValue($object, $field) < $value; + }; + + case Comparison::LTE: + return static function ($object) use ($field, $value): bool { + return ClosureExpressionVisitor::getObjectFieldValue($object, $field) <= $value; + }; + + case Comparison::GT: + return static function ($object) use ($field, $value): bool { + return ClosureExpressionVisitor::getObjectFieldValue($object, $field) > $value; + }; + + case Comparison::GTE: + return static function ($object) use ($field, $value): bool { + return ClosureExpressionVisitor::getObjectFieldValue($object, $field) >= $value; + }; + + case Comparison::IN: + return static function ($object) use ($field, $value): bool { + $fieldValue = ClosureExpressionVisitor::getObjectFieldValue($object, $field); + + return in_array($fieldValue, $value, is_scalar($fieldValue)); + }; + + case Comparison::NIN: + return static function ($object) use ($field, $value): bool { + $fieldValue = ClosureExpressionVisitor::getObjectFieldValue($object, $field); + + return ! in_array($fieldValue, $value, is_scalar($fieldValue)); + }; + + case Comparison::CONTAINS: + return static function ($object) use ($field, $value) { + return strpos(ClosureExpressionVisitor::getObjectFieldValue($object, $field), $value) !== false; + }; + + case Comparison::MEMBER_OF: + return static function ($object) use ($field, $value): bool { + $fieldValues = ClosureExpressionVisitor::getObjectFieldValue($object, $field); + + if (! is_array($fieldValues)) { + $fieldValues = iterator_to_array($fieldValues); + } + + return in_array($value, $fieldValues, true); + }; + + case Comparison::STARTS_WITH: + return static function ($object) use ($field, $value): bool { + return strpos(ClosureExpressionVisitor::getObjectFieldValue($object, $field), $value) === 0; + }; + + case Comparison::ENDS_WITH: + return static function ($object) use ($field, $value): bool { + return $value === substr(ClosureExpressionVisitor::getObjectFieldValue($object, $field), -strlen($value)); + }; + + default: + throw new RuntimeException('Unknown comparison operator: ' . $comparison->getOperator()); + } + } + + /** + * {@inheritDoc} + */ + public function walkValue(Value $value) + { + return $value->getValue(); + } + + /** + * {@inheritDoc} + */ + public function walkCompositeExpression(CompositeExpression $expr) + { + $expressionList = []; + + foreach ($expr->getExpressionList() as $child) { + $expressionList[] = $this->dispatch($child); + } + + switch ($expr->getType()) { + case CompositeExpression::TYPE_AND: + return $this->andExpressions($expressionList); + + case CompositeExpression::TYPE_OR: + return $this->orExpressions($expressionList); + + default: + throw new RuntimeException('Unknown composite ' . $expr->getType()); + } + } + + /** + * @param callable[] $expressions + */ + private function andExpressions(array $expressions): callable + { + return static function ($object) use ($expressions): bool { + foreach ($expressions as $expression) { + if (! $expression($object)) { + return false; + } + } + + return true; + }; + } + + /** + * @param callable[] $expressions + */ + private function orExpressions(array $expressions): callable + { + return static function ($object) use ($expressions): bool { + foreach ($expressions as $expression) { + if ($expression($object)) { + return true; + } + } + + return false; + }; + } +} diff --git a/app/lib/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/Comparison.php b/app/lib/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/Comparison.php new file mode 100644 index 00000000..13e193cb --- /dev/null +++ b/app/lib/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/Comparison.php @@ -0,0 +1,80 @@ +'; + public const LT = '<'; + public const LTE = '<='; + public const GT = '>'; + public const GTE = '>='; + public const IS = '='; // no difference with EQ + public const IN = 'IN'; + public const NIN = 'NIN'; + public const CONTAINS = 'CONTAINS'; + public const MEMBER_OF = 'MEMBER_OF'; + public const STARTS_WITH = 'STARTS_WITH'; + public const ENDS_WITH = 'ENDS_WITH'; + + /** @var string */ + private $field; + + /** @var string */ + private $op; + + /** @var Value */ + private $value; + + /** + * @param string $field + * @param string $operator + * @param mixed $value + */ + public function __construct($field, $operator, $value) + { + if (! ($value instanceof Value)) { + $value = new Value($value); + } + + $this->field = $field; + $this->op = $operator; + $this->value = $value; + } + + /** + * @return string + */ + public function getField() + { + return $this->field; + } + + /** + * @return Value + */ + public function getValue() + { + return $this->value; + } + + /** + * @return string + */ + public function getOperator() + { + return $this->op; + } + + /** + * {@inheritDoc} + */ + public function visit(ExpressionVisitor $visitor) + { + return $visitor->walkComparison($this); + } +} diff --git a/app/lib/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/CompositeExpression.php b/app/lib/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/CompositeExpression.php new file mode 100644 index 00000000..924942bd --- /dev/null +++ b/app/lib/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/CompositeExpression.php @@ -0,0 +1,69 @@ +type = $type; + + foreach ($expressions as $expr) { + if ($expr instanceof Value) { + throw new RuntimeException('Values are not supported expressions as children of and/or expressions.'); + } + + if (! ($expr instanceof Expression)) { + throw new RuntimeException('No expression given to CompositeExpression.'); + } + + $this->expressions[] = $expr; + } + } + + /** + * Returns the list of expressions nested in this composite. + * + * @return Expression[] + */ + public function getExpressionList() + { + return $this->expressions; + } + + /** + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * {@inheritDoc} + */ + public function visit(ExpressionVisitor $visitor) + { + return $visitor->walkCompositeExpression($this); + } +} diff --git a/app/lib/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/Expression.php b/app/lib/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/Expression.php new file mode 100644 index 00000000..f40d529b --- /dev/null +++ b/app/lib/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/Expression.php @@ -0,0 +1,14 @@ +walkComparison($expr); + + case $expr instanceof Value: + return $this->walkValue($expr); + + case $expr instanceof CompositeExpression: + return $this->walkCompositeExpression($expr); + + default: + throw new RuntimeException('Unknown Expression ' . get_class($expr)); + } + } +} diff --git a/app/lib/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/Value.php b/app/lib/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/Value.php new file mode 100644 index 00000000..0830286e --- /dev/null +++ b/app/lib/vendor/doctrine/collections/lib/Doctrine/Common/Collections/Expr/Value.php @@ -0,0 +1,33 @@ +value = $value; + } + + /** + * @return mixed + */ + public function getValue() + { + return $this->value; + } + + /** + * {@inheritDoc} + */ + public function visit(ExpressionVisitor $visitor) + { + return $visitor->walkValue($this); + } +} diff --git a/app/lib/vendor/doctrine/collections/lib/Doctrine/Common/Collections/ExpressionBuilder.php b/app/lib/vendor/doctrine/collections/lib/Doctrine/Common/Collections/ExpressionBuilder.php new file mode 100644 index 00000000..ebb21caa --- /dev/null +++ b/app/lib/vendor/doctrine/collections/lib/Doctrine/Common/Collections/ExpressionBuilder.php @@ -0,0 +1,181 @@ + + * @psalm-return Collection + */ + public function matching(Criteria $criteria); +} diff --git a/app/lib/vendor/doctrine/collections/phpstan.neon.dist b/app/lib/vendor/doctrine/collections/phpstan.neon.dist new file mode 100644 index 00000000..9fa9195a --- /dev/null +++ b/app/lib/vendor/doctrine/collections/phpstan.neon.dist @@ -0,0 +1,17 @@ +parameters: + level: 3 + paths: + - lib + ignoreErrors: + # Making classes final as suggested would be a BC-break + - + message: '~Unsafe usage of new static\(\)\.~' + paths: + - 'lib/Doctrine/Common/Collections/ArrayCollection.php' + - 'lib/Doctrine/Common/Collections/Criteria.php' + - + message: '~Array \(array\\) does not accept key int\.~' + path: 'lib/Doctrine/Common/Collections/ArrayCollection.php' + + # This class is new in PHP 8.1 and PHPStan does not know it yet. + - '/Attribute class ReturnTypeWillChange does not exist./' diff --git a/app/lib/vendor/doctrine/collections/psalm.xml.dist b/app/lib/vendor/doctrine/collections/psalm.xml.dist new file mode 100644 index 00000000..3b5d1111 --- /dev/null +++ b/app/lib/vendor/doctrine/collections/psalm.xml.dist @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/lib/vendor/simshaun/recurr/.gitattributes b/app/lib/vendor/simshaun/recurr/.gitattributes new file mode 100644 index 00000000..cb445a2a --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/.gitattributes @@ -0,0 +1,3 @@ +/.github export-ignore +/tests export-ignore +/phpunit.xml.dist export-ignore diff --git a/app/lib/vendor/simshaun/recurr/.gitignore b/app/lib/vendor/simshaun/recurr/.gitignore new file mode 100644 index 00000000..288e9f17 --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/.gitignore @@ -0,0 +1,4 @@ +/vendor/ +/.idea/ +/composer.lock +/.phpunit.result.cache \ No newline at end of file diff --git a/app/lib/vendor/simshaun/recurr/LICENSE b/app/lib/vendor/simshaun/recurr/LICENSE new file mode 100644 index 00000000..594ce5ab --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/LICENSE @@ -0,0 +1,50 @@ +Copyright (c) 2015 Shaun Simmons + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +---------------------------------------------- + +Recurr is heavily based on rrule.js: + +Copyright 2010, Jakub Roztocil and Lars Schöning + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. Neither the name of The author nor the names of its contributors may + be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR AND CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/app/lib/vendor/simshaun/recurr/README.md b/app/lib/vendor/simshaun/recurr/README.md new file mode 100644 index 00000000..f6adf0e7 --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/README.md @@ -0,0 +1,164 @@ +# Recurr + +[![tests](https://github.com/simshaun/recurr/workflows/tests/badge.svg)](https://github.com/simshaun/recurr/actions) +[![Latest Stable Version](https://poser.pugx.org/simshaun/recurr/v/stable.svg)](https://packagist.org/packages/simshaun/recurr) +[![Total Downloads](https://poser.pugx.org/simshaun/recurr/downloads.svg)](https://packagist.org/packages/simshaun/recurr) +[![Latest Unstable Version](https://poser.pugx.org/simshaun/recurr/v/unstable.svg)](https://packagist.org/packages/simshaun/recurr) +[![License](https://poser.pugx.org/simshaun/recurr/license.svg)](https://packagist.org/packages/simshaun/recurr) + +Recurr is a PHP library for working with recurrence rules ([RRULE](https://tools.ietf.org/html/rfc5545)) and converting them in to DateTime objects. + +Recurr was developed as a precursor for a calendar with recurring events, and is heavily inspired by [rrule.js](https://github.com/jkbr/rrule). + +Installing Recurr +------------ + +The recommended way to install Recurr is through [Composer](http://getcomposer.org). + +```bash +composer require simshaun/recurr +``` + +Using Recurr +----------- + +### Creating RRULE rule objects ### + +You can create a new Rule object by passing the ([RRULE](https://tools.ietf.org/html/rfc5545)) string or an array with the rule parts, the start date, end date (optional) and timezone. + +```php +$timezone = 'America/New_York'; +$startDate = new \DateTime('2013-06-12 20:00:00', new \DateTimeZone($timezone)); +$endDate = new \DateTime('2013-06-14 20:00:00', new \DateTimeZone($timezone)); // Optional +$rule = new \Recurr\Rule('FREQ=MONTHLY;COUNT=5', $startDate, $endDate, $timezone); +``` + +You can also use chained methods to build your rule programmatically and get the resulting RRULE. + +```php +$rule = (new \Recurr\Rule) + ->setStartDate($startDate) + ->setTimezone($timezone) + ->setFreq('DAILY') + ->setByDay(['MO', 'TU']) + ->setUntil(new \DateTime('2017-12-31')) +; + +echo $rule->getString(); //FREQ=DAILY;UNTIL=20171231T000000;BYDAY=MO,TU +``` + +### RRULE to DateTime objects ### + +```php +$transformer = new \Recurr\Transformer\ArrayTransformer(); + +print_r($transformer->transform($rule)); +``` + +1. `$transformer->transform(...)` returns a `RecurrenceCollection` of `Recurrence` objects. +2. Each `Recurrence` has `getStart()` and `getEnd()` methods that return a `\DateTime` object. +3. If the transformed `Rule` lacks an end date, `getEnd()` will return a `\DateTime` object equal to that of `getStart()`. + +> Note: The transformer has a "virtual" limit (default 732) on the number of objects it generates. +> This prevents the script from crashing on an infinitely recurring rule. +> You can change the virtual limit with an `ArrayTransformerConfig` object that you pass to `ArrayTransformer`. + +### Transformation Constraints ### + +Constraints are used by the ArrayTransformer to allow or prevent certain dates from being added to a `RecurrenceCollection`. Recurr provides the following constraints: + +- `AfterConstraint(\DateTime $after, $inc = false)` +- `BeforeConstraint(\DateTime $before, $inc = false)` +- `BetweenConstraint(\DateTime $after, \DateTime $before, $inc = false)` + +`$inc` defines what happens if `$after` or `$before` are themselves recurrences. If `$inc = true`, they will be included in the collection. For example, + +```php +$startDate = new \DateTime('2014-06-17 04:00:00'); +$rule = new \Recurr\Rule('FREQ=MONTHLY;COUNT=5', $startDate); +$transformer = new \Recurr\Transformer\ArrayTransformer(); + +$constraint = new \Recurr\Transformer\Constraint\BeforeConstraint(new \DateTime('2014-08-01 00:00:00')); +print_r($transformer->transform($rule, $constraint)); +``` + +> Note: If building your own constraint, it is important to know that dates which do not meet the constraint's requirements do **not** count toward the transformer's virtual limit. If you manually set your constraint's `$stopsTransformer` property to `false`, the transformer *might* crash via an infinite loop. See the `BetweenConstraint` for an example on how to prevent that. + +### Post-Transformation `RecurrenceCollection` Filters ### + +`RecurrenceCollection` provides the following chainable helper methods to filter out recurrences: + +- `startsBetween(\DateTime $after, \DateTime $before, $inc = false)` +- `startsBefore(\DateTime $before, $inc = false)` +- `startsAfter(\DateTime $after, $inc = false)` +- `endsBetween(\DateTime $after, \DateTime $before, $inc = false)` +- `endsBefore(\DateTime $before, $inc = false)` +- `endsAfter(\DateTime $after, $inc = false)` + +`$inc` defines what happens if `$after` or `$before` are themselves recurrences. If `$inc = true`, they will be included in the filtered collection. For example, + + pseudo... + 2014-06-01 startsBetween(2014-06-01, 2014-06-20) // false + 2014-06-01 startsBetween(2014-06-01, 2014-06-20, true) // true + +> Note: `RecurrenceCollection` extends the Doctrine project's [ArrayCollection](https://github.com/doctrine/collections/blob/master/lib/Doctrine/Common/Collections/ArrayCollection.php) class. + +RRULE to Text +-------------------------- + +Recurr supports transforming some recurrence rules into human readable text. +This feature is still in beta and only supports yearly, monthly, weekly, and daily frequencies. + +```php +$rule = new Rule('FREQ=YEARLY;INTERVAL=2;COUNT=3;', new \DateTime()); + +$textTransformer = new TextTransformer(); +echo $textTransformer->transform($rule); +``` + +If you need more than English you can pass in a translator with one of the +supported locales *(see translations folder)*. + +```php +$rule = new Rule('FREQ=YEARLY;INTERVAL=2;COUNT=3;', new \DateTime()); + +$textTransformer = new TextTransformer( + new \Recurr\Transformer\Translator('de') +); +echo $textTransformer->transform($rule); +``` + +Warnings +--------------- + +- **Monthly recurring rules ** + By default, if your start date is on the 29th, 30th, or 31st, Recurr will skip following months that don't have at least that many days. + *(e.g. Jan 31 + 1 month = March)* + +This behavior is configurable: + +```php +$timezone = 'America/New_York'; +$startDate = new \DateTime('2013-01-31 20:00:00', new \DateTimeZone($timezone)); +$rule = new \Recurr\Rule('FREQ=MONTHLY;COUNT=5', $startDate, null, $timezone); +$transformer = new \Recurr\Transformer\ArrayTransformer(); + +$transformerConfig = new \Recurr\Transformer\ArrayTransformerConfig(); +$transformerConfig->enableLastDayOfMonthFix(); +$transformer->setConfig($transformerConfig); + +print_r($transformer->transform($rule)); +// 2013-01-31, 2013-02-28, 2013-03-31, 2013-04-30, 2013-05-31 +``` + + +Contribute +---------- + +Feel free to comment or make pull requests. Please include tests with PRs. + + +License +------- + +Recurr is licensed under the MIT License. See the [LICENSE](./LICENSE) file for details. diff --git a/app/lib/vendor/simshaun/recurr/composer.json b/app/lib/vendor/simshaun/recurr/composer.json new file mode 100644 index 00000000..b9b009fd --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/composer.json @@ -0,0 +1,41 @@ +{ + "name": "simshaun/recurr", + "description": "PHP library for working with recurrence rules", + "keywords": ["rrule", "recurrence", "recurring", "events", "dates"], + "homepage": "https://github.com/simshaun/recurr", + "type": "library", + "license": "MIT", + "authors": [ + { + "name": "Shaun Simmons", + "email": "shaun@shaun.pub", + "homepage": "https://shaun.pub" + } + ], + "require": { + "php": "^7.2||^8.0", + "doctrine/collections": "~1.6" + }, + "require-dev": { + "phpunit/phpunit": "^8.5.16", + "symfony/yaml": "^5.3" + }, + "autoload": { + "psr-4": { + "Recurr\\": "src/Recurr/" + } + }, + "autoload-dev": { + "psr-4": { + "Recurr\\Test\\": "tests/Recurr/Test" + } + }, + "extra": { + "branch-alias": { + "dev-master": "0.x-dev" + } + }, + "scripts": { + "test": "./vendor/bin/phpunit --color=always" + } +} diff --git a/app/lib/vendor/simshaun/recurr/src/Recurr/DateExclusion.php b/app/lib/vendor/simshaun/recurr/src/Recurr/DateExclusion.php new file mode 100644 index 00000000..6ecb6ecf --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/src/Recurr/DateExclusion.php @@ -0,0 +1,48 @@ + + */ +class DateExclusion +{ + /** @var \DateTimeInterface */ + public $date; + + /** @var bool Day of year */ + public $hasTime; + + /** @var bool */ + public $isUtcExplicit; + + /** + * Constructor + * + * @param \DateTimeInterface $date + * @param bool $hasTime + * @param bool $isUtcExplicit + */ + public function __construct(\DateTimeInterface $date, $hasTime = true, $isUtcExplicit = false) + { + $this->date = $date; + $this->hasTime = $hasTime; + $this->isUtcExplicit = $isUtcExplicit; + } +} diff --git a/app/lib/vendor/simshaun/recurr/src/Recurr/DateInclusion.php b/app/lib/vendor/simshaun/recurr/src/Recurr/DateInclusion.php new file mode 100644 index 00000000..0ee6e84c --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/src/Recurr/DateInclusion.php @@ -0,0 +1,48 @@ + + */ +class DateInclusion +{ + /** @var \DateTimeInterface */ + public $date; + + /** @var bool Day of year */ + public $hasTime; + + /** @var bool */ + public $isUtcExplicit; + + /** + * Constructor + * + * @param \DateTimeInterface $date + * @param bool $hasTime + * @param bool $isUtcExplicit + */ + public function __construct(\DateTimeInterface $date, $hasTime = true, $isUtcExplicit = false) + { + $this->date = $date; + $this->hasTime = $hasTime; + $this->isUtcExplicit = $isUtcExplicit; + } +} diff --git a/app/lib/vendor/simshaun/recurr/src/Recurr/DateInfo.php b/app/lib/vendor/simshaun/recurr/src/Recurr/DateInfo.php new file mode 100644 index 00000000..453734da --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/src/Recurr/DateInfo.php @@ -0,0 +1,73 @@ + + */ +class DateInfo +{ + /** @var \DateTime */ + public $dt; + + /** + * @var int Number of days in the month. + */ + public $monthLength; + + /** + * @var int Number of days in the year (365 normally, 366 on leap years) + */ + public $yearLength; + + /** + * @var int Number of days in the next year (365 normally, 366 on leap years) + */ + public $nextYearLength; + + /** + * @var array Day of year of last day of each month. + */ + public $mRanges; + + /** @var int Day of week */ + public $dayOfWeek; + + /** @var int Day of week of the year's first day */ + public $dayOfWeekYearDay1; + + /** + * @var array Month number for each day of the year. + */ + public $mMask; + + /** + * @var array Month-daynumber for each day of the year. + */ + public $mDayMask; + + /** + * @var array Month-daynumber for each day of the year (in reverse). + */ + public $mDayMaskNeg; + + /** + * @var array Day of week (0-6) for each day of the year, 0 being Monday + */ + public $wDayMask; +} diff --git a/app/lib/vendor/simshaun/recurr/src/Recurr/DateUtil.php b/app/lib/vendor/simshaun/recurr/src/Recurr/DateUtil.php new file mode 100644 index 00000000..48a4e874 --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/src/Recurr/DateUtil.php @@ -0,0 +1,571 @@ + + * Copyright (c) 2012 - Tomi Pieviläinen + */ + +namespace Recurr; + +/** + * Class DateUtil is responsible for providing utilities applicable to Rules. + * + * @package Recurr + * @author Shaun Simmons + */ +class DateUtil +{ + public static $leapBug = null; + + public static $monthEndDoY366 = array( + 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 + ); + + public static $monthEndDoY365 = array( + 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 + ); + + public static $wDayMask = array( + 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, + 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, + 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, + 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, + 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, + 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, + 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, + 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, + 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, + 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, + 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, + 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, + 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, + 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, + 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, + 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, + 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, + 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, + 0, 1, 2, 3, 4, 5, 6, + ); + + /** + * Get an object containing info for a particular date + * + * @param \DateTimeInterface $dt + * + * @return DateInfo + */ + public static function getDateInfo(\DateTimeInterface $dt) + { + $i = new DateInfo(); + $i->dt = $dt; + $i->dayOfWeek = self::getDayOfWeek($dt); + $i->monthLength = $dt->format('t'); + $i->yearLength = self::getYearLength($dt); + + $i->mMask = self::getMonthMask($dt); + $i->mDayMask = self::getMonthDaysMask($dt); + $i->mDayMaskNeg = self::getMonthDaysMask($dt, true); + + if ($i->yearLength == 365) { + $i->mRanges = self::$monthEndDoY365; + } else { + $i->mRanges = self::$monthEndDoY366; + } + + $tmpDt = clone $dt; + $tmpDt = $tmpDt->setDate($dt->format('Y') + 1, 1, 1); + $i->nextYearLength = self::getYearLength($tmpDt); + + $tmpDt = clone $dt; + $tmpDt = $tmpDt->setDate($dt->format('Y'), 1, 1); + $i->dayOfWeekYearDay1 = self::getDayOfWeek($tmpDt); + + $i->wDayMask = array_slice( + self::$wDayMask, + $i->dayOfWeekYearDay1 + ); + + return $i; + } + + /** + * Get an array of DOY (Day of Year) for each day in a particular week. + * + * @param \DateTimeInterface $dt + * @param \DateTimeInterface $start + * @param null|Rule $rule + * @param null|DateInfo $dtInfo + * + * @return DaySet + */ + public static function getDaySetOfWeek( + \DateTimeInterface $dt, + \DateTimeInterface $start, + Rule $rule = null, + DateInfo $dtInfo = null + ) + { + $start = clone $dt; + $start = $start->setDate($start->format('Y'), 1, 1); + + $diff = $dt->diff($start); + $start = $diff->days; + + $set = array(); + for ($i = $start, $k = 0; $k < 7; $k++) { + $set[] = $i; + ++$i; + + if (null !== $dtInfo && null !== $rule && $dtInfo->wDayMask[$i] == $rule->getWeekStartAsNum()) { + break; + } + } + + $obj = new DaySet($set, $start, $i); + + return $obj; + } + + /** + * @param Rule $rule + * @param \DateTimeInterface $dt + * @param DateInfo $dtInfo + * @param \DateTimeInterface $start + * + * @return DaySet + */ + public static function getDaySet(Rule $rule, \DateTimeInterface $dt, DateInfo $dtInfo, $start) + { + switch ($rule->getFreq()) { + case Frequency::SECONDLY: + return self::getDaySetOfDay($dt, $start, $rule, $dtInfo); + break; + case Frequency::MINUTELY: + return self::getDaySetOfDay($dt, $start, $rule, $dtInfo); + break; + case Frequency::HOURLY: + return self::getDaySetOfDay($dt, $start, $rule, $dtInfo); + break; + case Frequency::DAILY: + return self::getDaySetOfDay($dt, $start, $rule, $dtInfo); + break; + case Frequency::WEEKLY: + return self::getDaySetOfWeek($dt, $start, $rule, $dtInfo); + case Frequency::MONTHLY: + return self::getDaySetOfMonth($dt, $start, $rule, $dtInfo); + case Frequency::YEARLY: + return self::getDaySetOfYear($dt, $start, $rule, $dtInfo); + } + + throw new \RuntimeException('Invalid freq.'); + } + + /** + * Get an array of DOY (Day of Year) for each day in a particular year. + * + * @param \DateTimeInterface $dt The datetime + * + * @return DaySet + */ + public static function getDaySetOfYear(\DateTimeInterface $dt) + { + $yearLen = self::getYearLength($dt); + $set = range(0, $yearLen - 1); + + return new DaySet($set, 0, $yearLen); + } + + /** + * Get an array of DOY (Day of Year) for each day in a particular month. + * + * @param \DateTimeInterface $dt The datetime + * + * @return DaySet + */ + public static function getDaySetOfMonth(\DateTimeInterface $dt) + { + $dateInfo = self::getDateInfo($dt); + $monthNum = $dt->format('n'); + + $start = $dateInfo->mRanges[$monthNum - 1]; + $end = $dateInfo->mRanges[$monthNum]; + + $days = range(0, $dt->format('t') - 1); + $set = range($start, $end - 1); + $set = array_combine($days, $set); + $obj = new DaySet($set, $start, $end - 1); + + return $obj; + } + + /** + * Get an array of DOY (Day of Year) for each day in a particular month. + * + * @param \DateTimeInterface $dt The datetime + * + * @return DaySet + */ + public static function getDaySetOfDay(\DateTimeInterface $dt) + { + $dayOfYear = $dt->format('z'); + + if (self::isLeapYearDate($dt) && self::hasLeapYearBug() && $dt->format('nj') > 229) { + $dayOfYear -= 1; + } + + $start = $dayOfYear; + $end = $dayOfYear; + + $set = range($start, $end); + $obj = new DaySet($set, $start, $end + 1); + + return $obj; + } + + /** + * @param Rule $rule + * @param \DateTimeInterface $dt + * + * @return array + */ + public static function getTimeSetOfHour(Rule $rule, \DateTimeInterface $dt) + { + $set = array(); + + $hour = $dt->format('G'); + $byMinute = $rule->getByMinute(); + $bySecond = $rule->getBySecond(); + + if (empty($byMinute)) { + $byMinute = array($dt->format('i')); + } + + if (empty($bySecond)) { + $bySecond = array($dt->format('s')); + } + + foreach ($byMinute as $minute) { + foreach ($bySecond as $second) { + $set[] = new Time($hour, $minute, $second); + } + } + + return $set; + } + + /** + * @param Rule $rule + * @param \DateTimeInterface $dt + * + * @return array + */ + public static function getTimeSetOfMinute(Rule $rule, \DateTimeInterface $dt) + { + $set = array(); + + $hour = $dt->format('G'); + $minute = $dt->format('i'); + $bySecond = $rule->getBySecond(); + + if (empty($bySecond)) { + $bySecond = array($dt->format('s')); + } + + foreach ($bySecond as $second) { + $set[] = new Time($hour, $minute, $second); + } + + return $set; + } + + /** + * @param \DateTimeInterface $dt + * + * @return array + */ + public static function getTimeSetOfSecond(\DateTimeInterface $dt) + { + return array(new Time($dt->format('G'), $dt->format('i'), $dt->format('s'))); + } + + /** + * @param Rule $rule + * @param \DateTimeInterface $dt + * + * @return array + */ + public static function getTimeSet(Rule $rule, \DateTimeInterface $dt) + { + $set = array(); + + if (null === $rule || $rule->getFreq() >= Frequency::HOURLY) { + return $set; + } + + $byHour = $rule->getByHour(); + $byMinute = $rule->getByMinute(); + $bySecond = $rule->getBySecond(); + + if (empty($byHour)) { + $byHour = array($dt->format('G')); + } + + if (empty($byMinute)) { + $byMinute = array($dt->format('i')); + } + + if (empty($bySecond)) { + $bySecond = array($dt->format('s')); + } + + foreach ($byHour as $hour) { + foreach ($byMinute as $minute) { + foreach ($bySecond as $second) { + $set[] = new Time($hour, $minute, $second); + } + } + } + + return $set; + } + + /** + * Get a reference array with the day number for each day of each month. + * + * @param \DateTimeInterface $dt The datetime + * @param bool $negative + * + * @return array + */ + public static function getMonthDaysMask(\DateTimeInterface $dt, $negative = false) + { + if ($negative) { + $m29 = range(-29, -1); + $m30 = range(-30, -1); + $m31 = range(-31, -1); + } else { + $m29 = range(1, 29); + $m30 = range(1, 30); + $m31 = range(1, 31); + } + + $mask = array_merge( + $m31, // Jan (31) + $m29, // Feb (28) + $m31, // Mar (31) + $m30, // Apr (30) + $m31, // May (31) + $m30, // Jun (30) + $m31, // Jul (31) + $m31, // Aug (31) + $m30, // Sep (30) + $m31, // Oct (31) + $m30, // Nov (30) + $m31, // Dec (31) + array_slice( + $m31, + 0, + 7 + ) + ); + + if (self::isLeapYearDate($dt)) { + return $mask; + } else { + if ($negative) { + $mask = array_merge(array_slice($mask, 0, 31), array_slice($mask, 32)); + } else { + $mask = array_merge(array_slice($mask, 0, 59), array_slice($mask, 60)); + } + + return $mask; + } + } + + public static function getMonthMask(\DateTimeInterface $dt) + { + if (self::isLeapYearDate($dt)) { + return array_merge( + array_fill(0, 31, 1), // Jan (31) + array_fill(0, 29, 2), // Feb (29) + array_fill(0, 31, 3), // Mar (31) + array_fill(0, 30, 4), // Apr (30) + array_fill(0, 31, 5), // May (31) + array_fill(0, 30, 6), // Jun (30) + array_fill(0, 31, 7), // Jul (31) + array_fill(0, 31, 8), // Aug (31) + array_fill(0, 30, 9), // Sep (30) + array_fill(0, 31, 10), // Oct (31) + array_fill(0, 30, 11), // Nov (30) + array_fill(0, 31, 12), // Dec (31) + array_fill(0, 7, 1) + ); + } else { + return array_merge( + array_fill(0, 31, 1), // Jan (31) + array_fill(0, 28, 2), // Feb (28) + array_fill(0, 31, 3), // Mar (31) + array_fill(0, 30, 4), // Apr (30) + array_fill(0, 31, 5), // May (31) + array_fill(0, 30, 6), // Jun (30) + array_fill(0, 31, 7), // Jul (31) + array_fill(0, 31, 8), // Aug (31) + array_fill(0, 30, 9), // Sep (30) + array_fill(0, 31, 10), // Oct (31) + array_fill(0, 30, 11), // Nov (30) + array_fill(0, 31, 12), // Dec (31) + array_fill(0, 7, 1) + ); + } + } + + public static function getDateTimeByDayOfYear($dayOfYear, $year, \DateTimeZone $timezone) + { + $dtTmp = new \DateTime('now', $timezone); + $dtTmp = $dtTmp->setDate($year, 1, 1); + $dtTmp = $dtTmp->modify("+$dayOfYear day"); + + return $dtTmp; + } + + public static function hasLeapYearBug() + { + $leapBugTest = \DateTime::createFromFormat('Y-m-d', '2016-03-21'); + return $leapBugTest->format('z') != '80'; + } + + /** + * closure/goog/math/math.js:modulo + * Copyright 2006 The Closure Library Authors. + * + * The % operator in PHP returns the remainder of a / b, but differs from + * some other languages in that the result will have the same sign as the + * dividend. For example, -1 % 8 == -1, whereas in some other languages + * (such as Python) the result would be 7. This function emulates the more + * correct modulo behavior, which is useful for certain applications such as + * calculating an offset index in a circular list. + * + * @param int $a The dividend. + * @param int $b The divisor. + * + * @return int $a % $b where the result is between 0 and $b + * (either 0 <= x < $b + * or $b < x <= 0, depending on the sign of $b). + */ + public static function pymod($a, $b) + { + $x = $a % $b; + + // If $x and $b differ in sign, add $b to wrap the result to the correct sign. + return ($x * $b < 0) ? $x + $b : $x; + } + + /** + * Alias method to determine if a date falls within a leap year. + * + * @param \DateTimeInterface $dt + * + * @return bool + */ + public static function isLeapYearDate(\DateTimeInterface $dt) + { + return $dt->format('L') ? true : false; + } + + /** + * Alias method to determine if a year is a leap year. + * + * @param int $year + * + * @return bool + */ + public static function isLeapYear($year) + { + $isDivisBy4 = $year % 4 == 0 ? true : false; + $isDivisBy100 = $year % 100 == 0? true : false; + $isDivisBy400 = $year % 400 == 0 ? true : false; + + // http://en.wikipedia.org/wiki/February_29 + if ($isDivisBy100 && !$isDivisBy400) { + return false; + } + + return $isDivisBy4; + } + + /** + * Method to determine the day of the week from MO-SU. + * + * MO = Monday + * TU = Tuesday + * WE = Wednesday + * TH = Thursday + * FR = Friday + * SA = Saturday + * SU = Sunday + * + * @param \DateTimeInterface $dt + * + * @return string + */ + public static function getDayOfWeekAsText(\DateTimeInterface $dt) + { + $dayOfWeek = $dt->format('w') - 1; + + if ($dayOfWeek < 0) { + $dayOfWeek = 6; + } + + $map = array('MO', 'TU', 'WE', 'TH', 'FR', 'SA', 'SU'); + + return $map[$dayOfWeek]; + } + + /** + * Alias method to determine the day of the week from 0-6. + * + * 0 = Monday + * 1 = Tuesday + * 2 = Wednesday + * 3 = Thursday + * 4 = Friday + * 5 = Saturday + * 6 = Sunday + * + * @param \DateTimeInterface $dt + * + * @return int + */ + public static function getDayOfWeek(\DateTimeInterface $dt) + { + $dayOfWeek = $dt->format('w') - 1; + + if ($dayOfWeek < 0) { + $dayOfWeek = 6; + } + + return $dayOfWeek; + } + + /** + * Get the number of days in a year. + * + * @param \DateTimeInterface $dt + * + * @return int + */ + public static function getYearLength(\DateTimeInterface $dt) + { + return self::isLeapYearDate($dt) ? 366 : 365; + } +} diff --git a/app/lib/vendor/simshaun/recurr/src/Recurr/DaySet.php b/app/lib/vendor/simshaun/recurr/src/Recurr/DaySet.php new file mode 100644 index 00000000..6162e414 --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/src/Recurr/DaySet.php @@ -0,0 +1,46 @@ + + */ +class DaySet +{ + /** @var array */ + public $set; + + /** @var int Day of year */ + public $start; + + /** @var int Day of year */ + public $end; + + /** + * Constructor + * + * @param array $set Set of days + * @param int $start Day of year of start day + * @param int $end Day of year of end day + */ + public function __construct($set, $start, $end) + { + $this->set = $set; + $this->start = $start; + $this->end = $end; + } +} diff --git a/app/lib/vendor/simshaun/recurr/src/Recurr/Exception.php b/app/lib/vendor/simshaun/recurr/src/Recurr/Exception.php new file mode 100644 index 00000000..d0d8c6b4 --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/src/Recurr/Exception.php @@ -0,0 +1,17 @@ + + */ +class InvalidArgument extends Exception +{ +} diff --git a/app/lib/vendor/simshaun/recurr/src/Recurr/Exception/InvalidRRule.php b/app/lib/vendor/simshaun/recurr/src/Recurr/Exception/InvalidRRule.php new file mode 100644 index 00000000..cbd26922 --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/src/Recurr/Exception/InvalidRRule.php @@ -0,0 +1,20 @@ + + */ +class InvalidRRule extends Exception +{ +} diff --git a/app/lib/vendor/simshaun/recurr/src/Recurr/Exception/InvalidWeekday.php b/app/lib/vendor/simshaun/recurr/src/Recurr/Exception/InvalidWeekday.php new file mode 100644 index 00000000..041a7738 --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/src/Recurr/Exception/InvalidWeekday.php @@ -0,0 +1,20 @@ + + */ +class InvalidWeekday extends Exception +{ +} diff --git a/app/lib/vendor/simshaun/recurr/src/Recurr/Frequency.php b/app/lib/vendor/simshaun/recurr/src/Recurr/Frequency.php new file mode 100644 index 00000000..e5d277b4 --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/src/Recurr/Frequency.php @@ -0,0 +1,25 @@ + + */ +class Recurrence +{ + /** @var \DateTimeInterface */ + protected $start; + + /** @var \DateTimeInterface */ + protected $end; + + /** @var int */ + protected $index; + + public function __construct(\DateTimeInterface $start = null, \DateTimeInterface $end = null, $index = 0) + { + if ($start instanceof \DateTimeInterface) { + $this->setStart($start); + } + + if ($end instanceof \DateTimeInterface) { + $this->setEnd($end); + } + + $this->index = $index; + } + + /** + * @return \DateTimeInterface + */ + public function getStart() + { + return $this->start; + } + + /** + * @param \DateTime $start + */ + public function setStart($start) + { + $this->start = $start; + } + + /** + * @return \DateTime + */ + public function getEnd() + { + return $this->end; + } + + /** + * @param \DateTime $end + */ + public function setEnd($end) + { + $this->end = $end; + } + + /** + * @return int + */ + public function getIndex() + { + return $this->index; + } + + /** + * @param int $index + */ + public function setIndex($index) + { + $this->index = $index; + } +} diff --git a/app/lib/vendor/simshaun/recurr/src/Recurr/RecurrenceCollection.php b/app/lib/vendor/simshaun/recurr/src/Recurr/RecurrenceCollection.php new file mode 100644 index 00000000..e1e676bd --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/src/Recurr/RecurrenceCollection.php @@ -0,0 +1,153 @@ + + */ +class RecurrenceCollection extends BaseCollection +{ + /** + * @param \DateTimeInterface $after + * @param \DateTimeInterface $before + * @param bool $inc Include $after or $before if they happen to be a recurrence. + * + * @return RecurrenceCollection + */ + public function startsBetween(\DateTimeInterface $after, \DateTimeInterface $before, $inc = false) + { + return $this->filter( + function ($recurrence) use ($after, $before, $inc) { + /** @var $recurrence Recurrence */ + $start = $recurrence->getStart(); + + if ($inc) { + return $start >= $after && $start <= $before; + } + + return $start > $after && $start < $before; + } + ); + } + + /** + * @param \DateTimeInterface $before + * @param bool $inc Include $before if it is a recurrence. + * + * @return RecurrenceCollection + */ + public function startsBefore(\DateTimeInterface $before, $inc = false) + { + return $this->filter( + function ($recurrence) use ($before, $inc) { + /** @var $recurrence Recurrence */ + $start = $recurrence->getStart(); + + if ($inc) { + return $start <= $before; + } + + return $start < $before; + } + ); + } + + /** + * @param \DateTimeInterface $after + * @param bool $inc Include $after if it a recurrence. + * + * @return RecurrenceCollection + */ + public function startsAfter(\DateTimeInterface $after, $inc = false) + { + return $this->filter( + function ($recurrence) use ($after, $inc) { + /** @var $recurrence Recurrence */ + $start = $recurrence->getStart(); + + if ($inc) { + return $start >= $after; + } + + return $start > $after; + } + ); + } + + /** + * @param \DateTimeInterface $after + * @param \DateTimeInterface $before + * @param bool $inc Include $after or $before if they happen to be a recurrence. + * + * @return RecurrenceCollection + */ + public function endsBetween(\DateTimeInterface $after, \DateTimeInterface $before, $inc = false) + { + return $this->filter( + function ($recurrence) use ($after, $before, $inc) { + /** @var $recurrence Recurrence */ + $end = $recurrence->getEnd(); + + if ($inc) { + return $end >= $after && $end <= $before; + } + + return $end > $after && $end < $before; + } + ); + } + + /** + * @param \DateTimeInterface $before + * @param bool $inc Include $before if it is a recurrence. + * + * @return RecurrenceCollection + */ + public function endsBefore(\DateTimeInterface $before, $inc = false) + { + return $this->filter( + function ($recurrence) use ($before, $inc) { + /** @var $recurrence Recurrence */ + $end = $recurrence->getEnd(); + + if ($inc) { + return $end <= $before; + } + + return $end < $before; + } + ); + } + + /** + * @param \DateTimeInterface $after + * @param bool $inc Include $after if it a recurrence. + * + * @return RecurrenceCollection + */ + public function endsAfter(\DateTimeInterface $after, $inc = false) + { + return $this->filter( + function ($recurrence) use ($after, $inc) { + /** @var $recurrence Recurrence */ + $end = $recurrence->getEnd(); + + if ($inc) { + return $end >= $after; + } + + return $end > $after; + } + ); + } +} diff --git a/app/lib/vendor/simshaun/recurr/src/Recurr/Rule.php b/app/lib/vendor/simshaun/recurr/src/Recurr/Rule.php new file mode 100644 index 00000000..dfcf40f0 --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/src/Recurr/Rule.php @@ -0,0 +1,1315 @@ + + * Copyright (c) 2012 - Tomi Pieviläinen + */ + +namespace Recurr; + +use Recurr\Exception\InvalidArgument; +use Recurr\Exception\InvalidRRule; +use Recurr\Exception\InvalidWeekday; + +/** + * This class is responsible for providing a programmatic way of building, + * parsing, and handling RRULEs. + * + * http://www.ietf.org/rfc/rfc2445.txt + * + * Information, not contained in the built/parsed RRULE, necessary to determine + * the various recurrence instance start time and dates are derived from the + * DTSTART property (default: \DateTime()). + * + * For example, "FREQ=YEARLY;BYMONTH=1" doesn't specify a specific day within + * the month or a time. This information would be the same as what is specified + * for DTSTART. + * + * + * BYxxx rule parts modify the recurrence in some manner. BYxxx rule parts for + * a period of time which is the same or greater than the frequency generally + * reduce or limit the number of occurrences of the recurrence generated. + * + * For example, "FREQ=DAILY;BYMONTH=1" reduces the number of recurrence + * instances from all days (if BYMONTH tag is not present) to all days in + * January. + * + * BYxxx rule parts for a period of time less than the frequency generally + * increase or expand the number of occurrences of the recurrence. + * + * For example, "FREQ=YEARLY;BYMONTH=1,2" increases the number of days within + * the yearly recurrence set from 1 (if BYMONTH tag is not present) to 2. + * + * If multiple BYxxx rule parts are specified, then after evaluating the + * specified FREQ and INTERVAL rule parts, the BYxxx rule parts are applied to + * the current set of evaluated occurrences in the following order: + * + * BYMONTH, BYWEEKNO, BYYEARDAY, BYMONTHDAY, BYDAY, BYHOUR, + * BYMINUTE, BYSECOND and BYSETPOS; then COUNT and UNTIL are evaluated. + * + * Here is an example of evaluating multiple BYxxx rule parts. + * + * FREQ=YEARLY;INTERVAL=2;BYMONTH=1;BYDAY=SU;BYHOUR=8,9;BYMINUTE=30 + * + * First, the "INTERVAL=2" would be applied to "FREQ=YEARLY" to arrive at + * "every other year". + * Then, "BYMONTH=1" would be applied to arrive at "every January, every + * other year". + * Then, "BYDAY=SU" would be applied to arrive at "every Sunday in January, + * every other year". + * Then, "BYHOUR=8,9" would be applied to arrive at "every Sunday in January + * at 8 AM and 9 AM, every other year". + * Then, "BYMINUTE=30" would be applied to arrive at "every Sunday in January + * at 8:30 AM and 9:30 AM, every other year". + * Then, lacking information from RRULE, the second is derived from DTSTART, to + * end up in "every Sunday in January at 8:30:00 AM and 9:30:00 AM, every + * other year". Similarly, if the BYMINUTE, BYHOUR, BYDAY, BYMONTHDAY or + * BYMONTH rule part were missing, the appropriate minute, hour, day or month + * would have been retrieved from the "DTSTART" property. + * + * Example: The following is a rule which specifies 10 meetings which occur + * every other day: + * + * FREQ=DAILY;COUNT=10;INTERVAL=2 + * + * @package Recurr + * @author Shaun Simmons + */ +class Rule +{ + const TZ_FIXED = 'fixed'; + const TZ_FLOAT = 'floating'; + + public static $freqs = array( + 'YEARLY' => 0, + 'MONTHLY' => 1, + 'WEEKLY' => 2, + 'DAILY' => 3, + 'HOURLY' => 4, + 'MINUTELY' => 5, + 'SECONDLY' => 6, + ); + + /** @var string */ + protected $timezone; + + /** @var \DateTimeInterface|null */ + protected $startDate; + + /** @var \DateTimeInterface|null */ + protected $endDate; + + /** @var bool */ + protected $isStartDateFromDtstart = false; + + /** @var string */ + protected $freq; + + /** @var int */ + protected $interval = 1; + + /** @var bool */ + protected $isExplicitInterval = false; + + /** @var \DateTimeInterface|null */ + protected $until; + + /** @var int|null */ + protected $count; + + /** @var array */ + protected $bySecond; + + /** @var array */ + protected $byMinute; + + /** @var array */ + protected $byHour; + + /** @var array */ + protected $byDay; + + /** @var array */ + protected $byMonthDay; + + /** @var array */ + protected $byYearDay; + + /** @var array */ + protected $byWeekNumber; + + /** @var array */ + protected $byMonth; + + /** @var string */ + protected $weekStart = 'MO'; + protected $weekStartDefined = false; + + /** @var array */ + protected $days = array( + 'MO' => 0, + 'TU' => 1, + 'WE' => 2, + 'TH' => 3, + 'FR' => 4, + 'SA' => 5, + 'SU' => 6 + ); + + /** @var int[] */ + protected $bySetPosition; + + /** @var array */ + protected $rDates = array(); + + /** @var array */ + protected $exDates = array(); + + /** + * Construct a new Rule. + * + * @param string $rrule RRULE string + * @param string|\DateTimeInterface|null $startDate + * @param string|\DateTimeInterface|null $endDate + * @param string $timezone + * + * @throws InvalidRRule + */ + public function __construct($rrule = null, $startDate = null, $endDate = null, $timezone = null) + { + if (empty($timezone)) { + if ($startDate instanceof \DateTimeInterface) { + $timezone = $startDate->getTimezone()->getName(); + } else { + $timezone = date_default_timezone_get(); + } + } + $this->setTimezone($timezone); + + if ($startDate !== null && !$startDate instanceof \DateTimeInterface) { + $startDate = new \DateTime($startDate, new \DateTimeZone($timezone)); + } + + $this->setStartDate($startDate); + + if ($endDate !== null && !$endDate instanceof \DateTimeInterface) { + $endDate = new \DateTime($endDate, new \DateTimeZone($timezone)); + } + + $this->setEndDate($endDate); + + if (is_array($rrule)) { + $this->loadFromArray($rrule); + } else if (!empty($rrule)) { + $this->loadFromString($rrule); + } + } + + /** + * Create a Rule object based on a RRULE string. + * + * @param string $rrule RRULE string + * @param string|\DateTimeInterface $startDate + * @param \DateTimeInterface|null $endDate + * @param string $timezone + * + * @return Rule + * @throws InvalidRRule + */ + public static function createFromString($rrule, $startDate = null, $endDate = null, $timezone = null) + { + $rule = new static($rrule, $startDate, $endDate, $timezone); + + return $rule; + } + + /** + * Create a Rule object based on a RRULE array. + * + * @param array $rrule RRULE array + * @param string|\DateTimeInterface $startDate + * @param \DateTimeInterface|null $endDate + * @param string $timezone + * + * @return Rule + * @throws InvalidRRule + */ + public static function createFromArray($rrule, $startDate = null, $endDate = null, $timezone = null) + { + $rule = new static($rrule, $startDate, $endDate, $timezone); + + return $rule; + } + + /** + * Populate the object based on a RRULE string. + * + * @param string $rrule RRULE string + * + * @return Rule + * @throws InvalidRRule + */ + public function loadFromString($rrule) + { + $rrule = strtoupper($rrule); + $rrule = trim($rrule, ';'); + $rrule = trim($rrule, "\n"); + $rows = explode("\n", $rrule); + + $parts = array(); + + foreach ($rows as $rruleForRow) { + $parts = array_merge($parts, $this->parseString($rruleForRow)); + } + + return $this->loadFromArray($parts); + } + + /** + * Parse string for parts + * + * @param string $rrule + * + * @return array + * + * @throws InvalidRRule + */ + public function parseString($rrule) + { + if (strpos($rrule, 'DTSTART:') === 0) { + $pieces = explode(':', $rrule); + + if (count($pieces) !== 2) { + throw new InvalidRRule('DSTART is not valid'); + } + + return array('DTSTART' => $pieces[1]); + } + + if (strpos($rrule, 'RRULE:') === 0) { + $rrule = str_replace('RRULE:', '', $rrule); + } + + $pieces = explode(';', $rrule); + $parts = array(); + + if (!count($pieces)) { + throw new InvalidRRule('RRULE is empty'); + } + + // Split each piece of the RRULE in to KEY=>VAL + foreach ($pieces as $piece) { + if (false === strpos($piece, '=')) { + continue; + } + + list($key, $val) = explode('=', $piece); + $parts[$key] = $val; + } + + return $parts; + } + + /** + * Populate the object based on a RRULE array. + * + * @param array + * + * @return Rule + * @throws InvalidRRule + */ + public function loadFromArray($parts) + { + // FREQ is required + if (!isset($parts['FREQ'])) { + throw new InvalidRRule('FREQ is required'); + } else { + if (!in_array($parts['FREQ'], array_keys(self::$freqs))) { + throw new InvalidRRule('FREQ is invalid'); + } + + $this->setFreq(self::$freqs[$parts['FREQ']]); + } + + // DTSTART + if (isset($parts['DTSTART'])) { + $this->isStartDateFromDtstart = true; + $date = new \DateTime($parts['DTSTART']); + $date = $date->setTimezone(new \DateTimeZone($this->getTimezone())); + $this->setStartDate($date); + } + + // DTEND + if (isset($parts['DTEND'])) { + $date = new \DateTime($parts['DTEND']); + $date = $date->setTimezone(new \DateTimeZone($this->getTimezone())); + $this->setEndDate($date); + } + + // UNTIL or COUNT + if (isset($parts['UNTIL']) && isset($parts['COUNT'])) { + throw new InvalidRRule('UNTIL and COUNT must not exist together in the same RRULE'); + } elseif (isset($parts['UNTIL'])) { + $date = new \DateTime($parts['UNTIL']); + $date = $date->setTimezone(new \DateTimeZone($this->getTimezone())); + $this->setUntil($date); + } elseif (isset($parts['COUNT'])) { + $this->setCount($parts['COUNT']); + } + + // INTERVAL + if (isset($parts['INTERVAL'])) { + $this->setInterval($parts['INTERVAL']); + } + + // BYSECOND + if (isset($parts['BYSECOND'])) { + $this->setBySecond(explode(',', $parts['BYSECOND'])); + } + + // BYMINUTE + if (isset($parts['BYMINUTE'])) { + $this->setByMinute(explode(',', $parts['BYMINUTE'])); + } + + // BYHOUR + if (isset($parts['BYHOUR'])) { + $this->setByHour(explode(',', $parts['BYHOUR'])); + } + + // BYDAY + if (isset($parts['BYDAY'])) { + $this->setByDay(explode(',', $parts['BYDAY'])); + } + + // BYMONTHDAY + if (isset($parts['BYMONTHDAY'])) { + $this->setByMonthDay(explode(',', $parts['BYMONTHDAY'])); + } + + // BYYEARDAY + if (isset($parts['BYYEARDAY'])) { + $this->setByYearDay(explode(',', $parts['BYYEARDAY'])); + } + + // BYWEEKNO + if (isset($parts['BYWEEKNO'])) { + $this->setByWeekNumber(explode(',', $parts['BYWEEKNO'])); + } + + // BYMONTH + if (isset($parts['BYMONTH'])) { + $this->setByMonth(explode(',', $parts['BYMONTH'])); + } + + // BYSETPOS + if (isset($parts['BYSETPOS'])) { + $this->setBySetPosition(explode(',', $parts['BYSETPOS'])); + } + + // WKST + if (isset($parts['WKST'])) { + $this->setWeekStart($parts['WKST']); + } + + // RDATE + if (isset($parts['RDATE'])) { + $this->setRDates(explode(',', $parts['RDATE'])); + } + + // EXDATE + if (isset($parts['EXDATE'])) { + $this->setExDates(explode(',', $parts['EXDATE'])); + } + + return $this; + } + + /** + * Get the RRULE as a string + * + * @param string $timezoneType + * + * @return string + */ + public function getString($timezoneType=self::TZ_FLOAT) + { + $format = 'Ymd\THis'; + + $parts = array(); + + // FREQ + $parts[] = 'FREQ='.$this->getFreqAsText(); + + // UNTIL or COUNT + $until = $this->getUntil(); + $count = $this->getCount(); + if (!empty($until)) { + if ($timezoneType === self::TZ_FIXED) { + $u = clone $until; + $u = $u->setTimezone(new \DateTimeZone('UTC')); + $parts[] = 'UNTIL='.$u->format($format.'\Z'); + } else { + $parts[] = 'UNTIL='.$until->format($format); + } + } elseif (!empty($count)) { + $parts[] = 'COUNT='.$count; + } + + // DTSTART + if ($this->isStartDateFromDtstart) { + if ($timezoneType === self::TZ_FIXED) { + $d = $this->getStartDate(); + $tzid = $d->getTimezone()->getName(); + $date = $d->format($format); + $parts[] = "DTSTART;TZID=$tzid:$date"; + } else { + $parts[] = 'DTSTART='.$this->getStartDate()->format($format); + } + } + + // DTEND + if ($this->endDate instanceof \DateTime) { + if ($timezoneType === self::TZ_FIXED) { + $d = $this->getEndDate(); + $tzid = $d->getTimezone()->getName(); + $date = $d->format($format); + + $parts[] = "DTEND;TZID=$tzid:$date"; + } else { + $parts[] = 'DTEND='.$this->getEndDate()->format($format); + } + } + + // INTERVAL + $interval = $this->getInterval(); + if ($this->isExplicitInterval && !empty($interval)) { + $parts[] = 'INTERVAL='.$interval; + } + + // BYSECOND + $bySecond = $this->getBySecond(); + if (!empty($bySecond)) { + $parts[] = 'BYSECOND='.implode(',', $bySecond); + } + + // BYMINUTE + $byMinute = $this->getByMinute(); + if (!empty($byMinute)) { + $parts[] = 'BYMINUTE='.implode(',', $byMinute); + } + + // BYHOUR + $byHour = $this->getByHour(); + if (!empty($byHour)) { + $parts[] = 'BYHOUR='.implode(',', $byHour); + } + + // BYDAY + $byDay = $this->getByDay(); + if (!empty($byDay)) { + $parts[] = 'BYDAY='.implode(',', $byDay); + } + + // BYMONTHDAY + $byMonthDay = $this->getByMonthDay(); + if (!empty($byMonthDay)) { + $parts[] = 'BYMONTHDAY='.implode(',', $byMonthDay); + } + + // BYYEARDAY + $byYearDay = $this->getByYearDay(); + if (!empty($byYearDay)) { + $parts[] = 'BYYEARDAY='.implode(',', $byYearDay); + } + + // BYWEEKNO + $byWeekNumber = $this->getByWeekNumber(); + if (!empty($byWeekNumber)) { + $parts[] = 'BYWEEKNO='.implode(',', $byWeekNumber); + } + + // BYMONTH + $byMonth = $this->getByMonth(); + if (!empty($byMonth)) { + $parts[] = 'BYMONTH='.implode(',', $byMonth); + } + + // BYSETPOS + $bySetPosition = $this->getBySetPosition(); + if (!empty($bySetPosition)) { + $parts[] = 'BYSETPOS='.implode(',', $bySetPosition); + } + + // WKST + $weekStart = $this->getWeekStart(); + if ($this->weekStartDefined && !empty($weekStart)) { + $parts[] = 'WKST='.$weekStart; + } + + // RDATE + $rDates = $this->getRDates(); + if (!empty($rDates)) { + foreach ($rDates as $key => $inclusion) { + $format = 'Ymd'; + if ($inclusion->hasTime) { + $format .= '\THis'; + if ($inclusion->isUtcExplicit) { + $format .= '\Z'; + } + } + $rDates[$key] = $inclusion->date->format($format); + } + $parts[] = 'RDATE='.implode(',', $rDates); + } + + // EXDATE + $exDates = $this->getExDates(); + if (!empty($exDates)) { + foreach ($exDates as $key => $exclusion) { + $format = 'Ymd'; + if ($exclusion->hasTime) { + $format .= '\THis'; + if ($exclusion->isUtcExplicit) { + $format .= '\Z'; + } + } + $exDates[$key] = $exclusion->date->format($format); + } + $parts[] = 'EXDATE='.implode(',', $exDates); + } + + return implode(';', $parts); + } + + /** + * @param string $timezone + * + * @see http://www.php.net/manual/en/timezones.php + * @return $this + */ + public function setTimezone($timezone) + { + $this->timezone = $timezone; + + return $this; + } + + /** + * Get timezone to use for \DateTimeInterface objects that are UTC. + * + * @return null|string + */ + public function getTimezone() + { + return $this->timezone; + } + + /** + * This date specifies the first instance in the recurrence set. + * + * @param \DateTimeInterface|null $startDate Date of the first instance in the recurrence + * @param bool|null $includeInString If true, include as DTSTART when calling getString() + * + * @return $this + */ + public function setStartDate($startDate, $includeInString = null) + { + $this->startDate = $startDate; + + if ($includeInString !== null) { + $this->isStartDateFromDtstart = (bool) $includeInString; + } + + return $this; + } + + /** + * @return \DateTimeInterface + */ + public function getStartDate() + { + return $this->startDate; + } + + /** + * This date specifies the last possible instance in the recurrence set. + * + * @param \DateTimeInterface|null $endDate Date of the last possible instance in the recurrence + * + * @return $this + */ + public function setEndDate($endDate) + { + $this->endDate = $endDate; + + return $this; + } + + /** + * @return \DateTimeInterface|null + */ + public function getEndDate() + { + return $this->endDate; + } + + /** + * Identifies the type of recurrence rule. + * + * May be one of: + * - Frequency::SECONDLY to specify repeating events based on an + * interval of a second or more. + * - Frequency::MINUTELY to specify repeating events based on an + * interval of a minute or more. + * - Frequency::HOURLY to specify repeating events based on an + * interval of an hour or more. + * - Frequency::DAILY to specify repeating events based on an + * interval of a day or more. + * - Frequency::WEEKLY to specify repeating events based on an + * interval of a week or more. + * - Frequency::MONTHLY to specify repeating events based on an + * interval of a month or more. + * - Frequency::YEAR to specify repeating events based on an + * interval of a year or more. + * + * @param string|int $freq Frequency of recurrence. + * + * @return $this + * @throws Exception\InvalidArgument + */ + public function setFreq($freq) + { + if (is_string($freq)) { + if (!array_key_exists($freq, self::$freqs)) { + throw new InvalidArgument('Frequency must comply with RFC 2445.'); + } else { + $freq = self::$freqs[$freq]; + } + } + + if (is_int($freq) && ($freq < 0 || $freq > 6)) { + throw new InvalidArgument('Frequency integer must be between 0 and 6 Use the class constants.'); + } + + $this->freq = $freq; + + return $this; + } + + /** + * Get the type of recurrence rule (as integer). + * + * @return int + */ + public function getFreq() + { + return $this->freq; + } + + /** + * Get the type of recurrence rule (as text). + * + * @return string + */ + public function getFreqAsText() + { + return array_search($this->getFreq(), self::$freqs); + } + + /** + * The interval represents how often the recurrence rule repeats. + * + * The default value is "1", meaning every second for a SECONDLY rule, + * or every minute for a MINUTELY rule, every hour for an HOURLY rule, + * every day for a DAILY rule, every week for a WEEKLY rule, every month + * for a MONTHLY rule and every year for a YEARLY rule. + * + * @param int $interval Positive integer that represents how often the + * recurrence rule repeats. + * + * @return $this + * @throws Exception\InvalidArgument + */ + public function setInterval($interval) + { + $interval = (int) $interval; + + if ($interval < 1) { + throw new InvalidArgument('Interval must be a positive integer'); + } + + $this->interval = $interval; + $this->isExplicitInterval = true; + + return $this; + } + + /** + * Get the interval that represents how often the recurrence rule repeats. + * + * @return int + */ + public function getInterval() + { + return $this->interval; + } + + /** + * Define a \DateTimeInterface value which bounds the recurrence rule in an + * inclusive manner. If the value specified is synchronized with the + * specified recurrence, this DateTime becomes the last instance of the + * recurrence. If not present, and a COUNT is also not present, the RRULE + * is considered to repeat forever. + * + * Either UNTIL or COUNT may be specified, but UNTIL and COUNT MUST NOT + * both be specified. + * + * @param \DateTimeInterface $until The upper bound of the recurrence. + * + * @return $this + */ + public function setUntil(\DateTimeInterface $until) + { + $this->until = $until; + $this->count = null; + + return $this; + } + + /** + * Get the \DateTimeInterface that the recurrence lasts until. + * + * @return \DateTimeInterface|null + */ + public function getUntil() + { + $date = $this->until; + + if ($date instanceof \DateTime + && $date->getTimezone()->getName() == 'UTC' + && $this->getTimezone() != 'UTC' + ) { + $timestamp = $date->getTimestamp(); + $date = $date->setTimezone(new \DateTimeZone($this->getTimezone())); + $date = $date->setTimestamp($timestamp); + } + + return $date; + } + + /** + * The count defines the number of occurrences at which to range-bound the + * recurrence. The DTSTART counts as the first occurrence. + * + * Either COUNT or UNTIL may be specified, but COUNT and UNTIL MUST NOT + * both be specified. + * + * @param int $count Number of occurrences + * + * @return $this + */ + public function setCount($count) + { + $this->count = (int) $count; + $this->until = null; + + return $this; + } + + /** + * Get the number of occurrences at which the recurrence is range-bound. + * + * @return int|null + */ + public function getCount() + { + return $this->count; + } + + /** + * This rule specifies an array of seconds within a minute. + * + * Valid values are 0 to 59. + * + * @param array $bySecond Array of seconds within a minute + * + * @return $this + */ + public function setBySecond(array $bySecond) + { + $this->bySecond = $bySecond; + + return $this; + } + + /** + * Get an array of seconds within a minute. + * + * @return array + */ + public function getBySecond() + { + return $this->bySecond; + } + + /** + * This rule specifies an array of minutes within an hour. + * + * Valid values are 0 to 59. + * + * @param array $byMinute Array of minutes within an hour + * + * @return $this + */ + public function setByMinute(array $byMinute) + { + $this->byMinute = $byMinute; + + return $this; + } + + /** + * Get an array of minutes within an hour. + * + * @return array + */ + public function getByMinute() + { + return $this->byMinute; + } + + /** + * This rule specifies an array of hours of the day. + * + * Valid values are 0 to 23. + * + * @param array $byHour Array of hours of the day + * + * @return $this + */ + public function setByHour(array $byHour) + { + $this->byHour = $byHour; + + return $this; + } + + /** + * Get an array of hours of the day. + * + * @return array + */ + public function getByHour() + { + return $this->byHour; + } + + /** + * This rule specifies an array of days of the week; + * + * MO indicates Monday; TU indicates Tuesday; WE indicates Wednesday; + * TH indicates Thursday; FR indicates Friday; SA indicates Saturday; + * SU indicates Sunday. + * + * Each BYDAY value can also be preceded by a positive (+n) or negative + * (-n) integer. If present, this indicates the nth occurrence of the + * specific day within the MONTHLY or YEARLY RRULE. For example, within + * a MONTHLY rule, +1MO (or simply 1MO) represents the first Monday + * within the month, whereas -1MO represents the last Monday of the + * month. If an integer modifier is not present, it means all days of + * this type within the specified frequency. For example, within a + * MONTHLY rule, MO represents all Mondays within the month. + * + * ------------------------------------------- + * DO NOT MIX DAYS AND DAYS WITH MODIFIERS. + * This is not supported. + * ------------------------------------------- + * + * @param array $byDay Array of days of the week + * + * @return $this + * @throws InvalidRRule + */ + public function setByDay(array $byDay) + { + if ($this->getFreq() > static::$freqs['MONTHLY'] && preg_match('/\d/', implode(',', $byDay))) { + throw new InvalidRRule('BYDAY only supports MONTHLY and YEARLY frequencies'); + } + if (count($byDay) === 0 || $byDay === array('')) { + throw new InvalidRRule('BYDAY must be set to at least one day'); + } + + $this->byDay = $byDay; + + return $this; + } + + /** + * Get an array of days of the week (SU, MO, TU, ..) + * + * @return array + */ + public function getByDay() + { + return $this->byDay; + } + + /** + * Get an array of Weekdays + * + * @return array of Weekdays + * @throws InvalidWeekday + */ + public function getByDayTransformedToWeekdays() + { + $byDay = $this->getByDay(); + + if (null === $byDay || !count($byDay)) { + return array(); + } + + foreach ($byDay as $idx => $day) { + if (strlen($day) === 2) { + $byDay[$idx] = new Weekday($day, null); + } else { + preg_match('/^([+-]?[0-9]+)([A-Z]{2})$/', $day, $dayParts); + $byDay[$idx] = new Weekday($dayParts[2], $dayParts[1]); + } + } + + return $byDay; + } + + /** + * This rule specifies an array of days of the month. + * Valid values are 1 to 31 or -31 to -1. + * + * For example, -10 represents the tenth to the last day of the month. + * + * @param array $byMonthDay Array of days of the month from -31 to 31 + * + * @return $this + */ + public function setByMonthDay(array $byMonthDay) + { + $this->byMonthDay = $byMonthDay; + + return $this; + } + + /** + * Get an array of days of the month. + * + * @return array + */ + public function getByMonthDay() + { + return $this->byMonthDay; + } + + /** + * This rule specifies an array of days of the year. + * Valid values are 1 to 366 or -366 to -1. + * + * For example, -1 represents the last day of the year (December 31st) and + * -306 represents the 306th to the last day of the year (March 1st). + * + * @param array $byYearDay Array of days of the year from -1 to 306 + * + * @return $this + */ + public function setByYearDay(array $byYearDay) + { + $this->byYearDay = $byYearDay; + + return $this; + } + + /** + * Get an array of days of the year. + * + * @return array + */ + public function getByYearDay() + { + return $this->byYearDay; + } + + /** + * This rule specifies an array of ordinals specifying weeks of the year. + * Valid values are 1 to 53 or -53 to -1. + * + * This corresponds to weeks according to week numbering as defined in + * [ISO 8601]. A week is defined as a seven day period, starting on the day + * of the week defined to be the week start (see setWeekStart). Week number + * one of the calendar year is the first week which contains at least four + * days in that calendar year. This rule is only valid for YEARLY rules. + * + * For example, 3 represents the third week of the year. + * + * Note: Assuming a Monday week start, week 53 can only occur when + * Thursday is January 1 or if it is a leap year and Wednesday is January 1. + * + * @param array $byWeekNumber Array of ordinals specifying weeks of the year. + * + * @return $this + */ + public function setByWeekNumber(array $byWeekNumber) + { + $this->byWeekNumber = $byWeekNumber; + + return $this; + } + + /** + * Get an array of ordinals specifying weeks of the year. + * + * @return array + */ + public function getByWeekNumber() + { + return $this->byWeekNumber; + } + + /** + * This rule specifies an array of months of the year. + * + * Valid values are 1 to 12. + * + * @param array $byMonth Array of months of the year from 1 to 12 + * + * @return $this + */ + public function setByMonth(array $byMonth) + { + $this->byMonth = $byMonth; + + return $this; + } + + /** + * Get an array of months of the year. + * + * @return array + */ + public function getByMonth() + { + return $this->byMonth; + } + + public function hasByMonth() + { + $val = $this->getByMonth(); + + return ! empty($val); + } + + /** + * This rule specifies the day on which the workweek starts. + * + * Valid values are MO, TU, WE, TH, FR, SA and SU. + * + * This is significant when a WEEKLY RRULE has an interval greater than 1, + * and a BYDAY rule part is specified. + * + * This is also significant when in a YEARLY RRULE when a BYWEEKNO rule + * is specified. The default value is MO. + * + * @param string $weekStart The day on which the workweek starts. + * + * @return $this + * @throws Exception\InvalidArgument + */ + public function setWeekStart($weekStart) + { + $weekStart = strtoupper($weekStart); + + if (!in_array($weekStart, array('MO', 'TU', 'WE', 'TH', 'FR', 'SA', 'SU'))) { + throw new InvalidArgument('Week Start must be one of MO, TU, WE, TH, FR, SA, SU'); + } + + $this->weekStart = $weekStart; + $this->weekStartDefined = true; + + return $this; + } + + /** + * Get the day on which the workweek starts. + * + * @return string + */ + public function getWeekStart() + { + return $this->weekStart; + } + + /** + * Get the day on which the workweek starts, as an integer from 0-6, + * 0 being Monday and 6 being Sunday. + * + * @return int + */ + public function getWeekStartAsNum() + { + $weekStart = $this->getWeekStart(); + + return $this->days[$weekStart]; + } + + /** + * This rule specifies an array of values which corresponds to the nth + * occurrence within the set of events specified by the rule. Valid values + * are 1 to 366 or -366 to -1. It MUST only be used in conjunction with + * another BYxxx rule part. + * + * For example "the last work day of the month" could be represented as: + * RRULE:FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-1 + * + * Each BYSETPOS value can include a positive or negative integer. + * If present, this indicates the nth occurrence of the specific occurrence + * within the set of events specified by the rule. + * + * @param array $bySetPosition Array of values which corresponds to the nth + * occurrence within the set of events specified by the rule. + * + * @return $this + */ + public function setBySetPosition($bySetPosition) + { + $this->bySetPosition = $bySetPosition; + + return $this; + } + + /** + * Get the array of values which corresponds to the nth occurrence within + * the set of events specified by the rule. + * + * @return array + */ + public function getBySetPosition() + { + return $this->bySetPosition; + } + + /** + * This rule specifies an array of dates that will be + * included in a recurrence set. + * + * @param string[]|DateInclusion[] $rDates Array of dates that will be + * included in the recurrence set. + * + * @return $this + */ + public function setRDates(array $rDates) + { + $timezone = new \DateTimeZone($this->getTimezone()); + + foreach ($rDates as $key => $val) { + if ($val instanceof DateInclusion) { + $val->date = $this->convertZtoUtc($val->date); + } else { + $date = new \DateTime($val, $timezone); + $rDates[$key] = new DateInclusion( + $this->convertZtoUtc($date), + strpos($val, 'T') !== false, + strpos($val, 'Z') !== false + ); + } + } + + $this->rDates = $rDates; + + return $this; + } + + /** + * Get the array of dates that will be included in a recurrence set. + * + * @return DateInclusion[] + */ + public function getRDates() + { + return $this->rDates; + } + + /** + * This rule specifies an array of exception dates that will not be + * included in a recurrence set. + * + * @param string[]|DateExclusion[] $exDates Array of dates that will not be + * included in the recurrence set. + * + * @return $this + */ + public function setExDates(array $exDates) + { + $timezone = new \DateTimeZone($this->getTimezone()); + + foreach ($exDates as $key => $val) { + if ($val instanceof DateExclusion) { + $val->date = $this->convertZtoUtc($val->date); + } else { + $date = new \DateTime($val, $timezone); + $exDates[$key] = new DateExclusion( + $this->convertZtoUtc($date), + strpos($val, 'T') !== false, + strpos($val, 'Z') !== false + ); + } + } + + $this->exDates = $exDates; + + return $this; + } + + /** + * DateTime::setTimezone fails if the timezone does not have an ID. + * "Z" is the same as "UTC", but "Z" does not have an ID. + * + * This is necessary for exclusion dates to be handled properly. + * + * @param \DateTimeInterface $date + * + * @return \DateTimeInterface + */ + private function convertZtoUtc(\DateTimeInterface $date) + { + if ($date->getTimezone()->getName() !== 'Z') { + return $date; + } + + return $date->setTimezone(new \DateTimeZone('UTC')); + } + + /** + * Get the array of dates that will not be included in a recurrence set. + * + * @return DateExclusion[] + */ + public function getExDates() + { + return $this->exDates; + } + + /** + * @return bool + */ + public function repeatsIndefinitely() + { + return !$this->getCount() && !$this->getUntil() && !$this->getEndDate(); + } +} diff --git a/app/lib/vendor/simshaun/recurr/src/Recurr/Time.php b/app/lib/vendor/simshaun/recurr/src/Recurr/Time.php new file mode 100644 index 00000000..c6360afb --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/src/Recurr/Time.php @@ -0,0 +1,39 @@ + + */ +class Time +{ + /** @var int */ + public $hour; + + /** @var int */ + public $minute; + + /** @var int */ + public $second; + + public function __construct($hour, $minute, $second) + { + $this->hour = $hour; + $this->minute = $minute; + $this->second = $second; + } +} diff --git a/app/lib/vendor/simshaun/recurr/src/Recurr/Transformer/ArrayTransformer.php b/app/lib/vendor/simshaun/recurr/src/Recurr/Transformer/ArrayTransformer.php new file mode 100644 index 00000000..414a3e6c --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/src/Recurr/Transformer/ArrayTransformer.php @@ -0,0 +1,736 @@ + + */ +class ArrayTransformer +{ + /** @var ArrayTransformerConfig */ + protected $config; + + /** + * Some versions of PHP are affected by a bug where + * \DateTimeInterface::createFromFormat('z Y', ...) does not account for leap years. + * + * @var bool + */ + protected $leapBug = false; + + /** + * Construct a new ArrayTransformer + * + * @param ArrayTransformerConfig $config + */ + public function __construct(ArrayTransformerConfig $config = null) + { + if (!$config instanceof ArrayTransformerConfig) { + $config = new ArrayTransformerConfig(); + } + + $this->config = $config; + + $this->leapBug = DateUtil::hasLeapYearBug(); + } + + /** + * @param ArrayTransformerConfig $config + */ + public function setConfig($config) + { + $this->config = $config; + } + + /** + * Transform a Rule in to an array of \DateTimeInterface objects + * + * @param Rule $rule the Rule object + * @param ConstraintInterface|null $constraint Potential recurrences must pass the constraint, else + * they will not be included in the returned collection. + * @param bool $countConstraintFailures Whether recurrences that fail the constraint's test + * should count towards a rule's COUNT limit. + * + * @return RecurrenceCollection|Recurrence[] + * @throws InvalidWeekday + */ + public function transform(Rule $rule, ConstraintInterface $constraint = null, $countConstraintFailures = true) + { + $start = $rule->getStartDate(); + $end = $rule->getEndDate(); + $until = $rule->getUntil(); + + if (null === $start) { + $start = new \DateTime( + 'now', $until instanceof \DateTimeInterface ? $until->getTimezone() : null + ); + } + + if (null === $end) { + $end = $start; + } + + $durationInterval = $start->diff($end); + + $startDay = $start->format('j'); + $startMonthLength = $start->format('t'); + $fixLastDayOfMonth = false; + + $dt = clone $start; + + $maxCount = $rule->getCount(); + $vLimit = $this->config->getVirtualLimit(); + + $freq = $rule->getFreq(); + $weekStart = $rule->getWeekStartAsNum(); + $bySecond = $rule->getBySecond(); + $byMinute = $rule->getByMinute(); + $byHour = $rule->getByHour(); + $byMonth = $rule->getByMonth(); + $byWeekNum = $rule->getByWeekNumber(); + $byYearDay = $rule->getByYearDay(); + $byMonthDay = $rule->getByMonthDay(); + $byMonthDayNeg = array(); + $byWeekDay = $rule->getByDayTransformedToWeekdays(); + $byWeekDayRel = array(); + $bySetPos = $rule->getBySetPosition(); + + $implicitByMonthDay = false; + if (!(!empty($byWeekNum) || !empty($byYearDay) || !empty($byMonthDay) || !empty($byWeekDay))) { + switch ($freq) { + case Frequency::YEARLY: + if (empty($byMonth)) { + $byMonth = array($start->format('n')); + } + + if ($startDay > 28) { + $fixLastDayOfMonth = true; + } + + $implicitByMonthDay = true; + $byMonthDay = array($startDay); + break; + case Frequency::MONTHLY: + if ($startDay > 28) { + $fixLastDayOfMonth = true; + } + + $implicitByMonthDay = true; + $byMonthDay = array($startDay); + break; + case Frequency::WEEKLY: + $byWeekDay = array( + new Weekday( + DateUtil::getDayOfWeek($start), null + ) + ); + break; + } + } + + if (!$this->config->isLastDayOfMonthFixEnabled()) { + $fixLastDayOfMonth = false; + } + + if (is_array($byMonthDay) && count($byMonthDay)) { + foreach ($byMonthDay as $idx => $day) { + if ($day < 0) { + unset($byMonthDay[$idx]); + $byMonthDayNeg[] = $day; + } + } + } + + if (!empty($byWeekDay)) { + foreach ($byWeekDay as $idx => $day) { + /** @var $day Weekday */ + + if (!empty($day->num)) { + $byWeekDayRel[] = $day; + unset($byWeekDay[$idx]); + } else { + $byWeekDay[$idx] = $day->weekday; + } + } + } + + if (empty($byYearDay)) { + $byYearDay = null; + } + + if (empty($byMonthDay)) { + $byMonthDay = null; + } + + if (empty($byMonthDayNeg)) { + $byMonthDayNeg = null; + } + + if (empty($byWeekDay)) { + $byWeekDay = null; + } + + if (!count($byWeekDayRel)) { + $byWeekDayRel = null; + } + + $year = $dt->format('Y'); + $month = $dt->format('n'); + $hour = $dt->format('G'); + $minute = $dt->format('i'); + $second = $dt->format('s'); + + $dates = array(); + $total = 1; + $count = $maxCount; + $continue = true; + $iterations = 0; + while ($continue) { + $dtInfo = DateUtil::getDateInfo($dt); + + $tmp = DateUtil::getDaySet($rule, $dt, $dtInfo, $start); + $daySet = $tmp->set; + $daySetStart = $tmp->start; + $daySetEnd = $tmp->end; + $wNoMask = array(); + $wDayMaskRel = array(); + $timeSet = DateUtil::getTimeSet($rule, $dt); + + if ($freq >= Frequency::HOURLY) { + if ( + ($freq >= Frequency::HOURLY && !empty($byHour) && !in_array($hour, $byHour)) + || ($freq >= Frequency::MINUTELY && !empty($byMinute) && !in_array($minute, $byMinute)) + || ($freq >= Frequency::SECONDLY && !empty($bySecond) && !in_array($second, $bySecond)) + ) { + $timeSet = array(); + } else { + switch ($freq) { + case Frequency::HOURLY: + $timeSet = DateUtil::getTimeSetOfHour($rule, $dt); + break; + case Frequency::MINUTELY: + $timeSet = DateUtil::getTimeSetOfMinute($rule, $dt); + break; + case Frequency::SECONDLY: + $timeSet = DateUtil::getTimeSetOfSecond($dt); + break; + } + } + } + + // Handle byWeekNum + if (!empty($byWeekNum)) { + $no1WeekStart = $firstWeekStart = DateUtil::pymod(7 - $dtInfo->dayOfWeekYearDay1 + $weekStart, 7); + + if ($no1WeekStart >= 4) { + $no1WeekStart = 0; + + $wYearLength = $dtInfo->yearLength + DateUtil::pymod( + $dtInfo->dayOfWeekYearDay1 - $weekStart, + 7 + ); + } else { + $wYearLength = $dtInfo->yearLength - $no1WeekStart; + } + + $div = floor($wYearLength / 7); + $mod = DateUtil::pymod($wYearLength, 7); + $numWeeks = floor($div + ($mod / 4)); + + foreach ($byWeekNum as $weekNum) { + if ($weekNum < 0) { + $weekNum += $numWeeks + 1; + } + + if (!(0 < $weekNum && $weekNum <= $numWeeks)) { + continue; + } + + if ($weekNum > 1) { + $offset = $no1WeekStart + ($weekNum - 1) * 7; + if ($no1WeekStart != $firstWeekStart) { + $offset -= 7 - $firstWeekStart; + } + } else { + $offset = $no1WeekStart; + } + + for ($i = 0; $i < 7; $i++) { + $wNoMask[] = $offset; + $offset++; + if ($dtInfo->wDayMask[$offset] == $weekStart) { + break; + } + } + } + + // Check week number 1 of next year as well + if (in_array(1, $byWeekNum)) { + $offset = $no1WeekStart + $numWeeks * 7; + + if ($no1WeekStart != $firstWeekStart) { + $offset -= 7 - $firstWeekStart; + } + + // If week starts in next year, we don't care about it. + if ($offset < $dtInfo->yearLength) { + for ($k = 0; $k < 7; $k++) { + $wNoMask[] = $offset; + $offset += 1; + if ($dtInfo->wDayMask[$offset] == $weekStart) { + break; + } + } + } + } + + if ($no1WeekStart) { + // Check last week number of last year as well. + // If $no1WeekStart is 0, either the year started on week start, + // or week number 1 got days from last year, so there are no + // days from last year's last week number in this year. + if (!in_array(-1, $byWeekNum)) { + $dtTmp = new \DateTime(); + $dtTmp = $dtTmp->setDate($year - 1, 1, 1); + $lastYearWeekDay = DateUtil::getDayOfWeek($dtTmp); + $lastYearNo1WeekStart = DateUtil::pymod(7 - $lastYearWeekDay + $weekStart, 7); + $lastYearLength = DateUtil::getYearLength($dtTmp); + if ($lastYearNo1WeekStart >= 4) { + $lastYearNo1WeekStart = 0; + $lastYearNumWeeks = floor( + 52 + DateUtil::pymod( + $lastYearLength + DateUtil::pymod( + $lastYearWeekDay - $weekStart, + 7 + ), + 7 + ) / 4 + ); + } else { + $lastYearNumWeeks = floor( + 52 + DateUtil::pymod( + $dtInfo->yearLength - $no1WeekStart, + 7 + ) / 4 + ); + } + } else { + $lastYearNumWeeks = -1; + } + + if (in_array($lastYearNumWeeks, $byWeekNum)) { + for ($i = 0; $i < $no1WeekStart; $i++) { + $wNoMask[] = $i; + } + } + } + } + + // Handle relative weekdays (e.g. 3rd Friday of month) + if (!empty($byWeekDayRel)) { + $ranges = array(); + + if (Frequency::YEARLY == $freq) { + if (!empty($byMonth)) { + foreach ($byMonth as $mo) { + $ranges[] = array_slice($dtInfo->mRanges, $mo - 1, 2); + } + } else { + $ranges[] = array(0, $dtInfo->yearLength); + } + } elseif (Frequency::MONTHLY == $freq) { + $ranges[] = array_slice($dtInfo->mRanges, $month - 1, 2); + } + + if (!empty($ranges)) { + foreach ($ranges as $range) { + $rangeStart = $range[0]; + $rangeEnd = $range[1]; + --$rangeEnd; + + reset($byWeekDayRel); + foreach ($byWeekDayRel as $weekday) { + /** @var Weekday $weekday */ + + if ($weekday->num < 0) { + $i = $rangeEnd + ($weekday->num + 1) * 7; + $i -= DateUtil::pymod( + $dtInfo->wDayMask[$i] - $weekday->weekday, + 7 + ); + } else { + $i = $rangeStart + ($weekday->num - 1) * 7; + $i += DateUtil::pymod( + 7 - $dtInfo->wDayMask[$i] + $weekday->weekday, + 7 + ); + } + + if ($rangeStart <= $i && $i <= $rangeEnd) { + $wDayMaskRel[] = $i; + } + } + } + } + } + + $numMatched = 0; + foreach ($daySet as $i => $dayOfYear) { + $dayOfMonth = $dtInfo->mDayMask[$dayOfYear]; + + $ifByMonth = $byMonth !== null && !in_array($dtInfo->mMask[$dayOfYear], $byMonth); + + $ifByWeekNum = $byWeekNum !== null && !in_array($i, $wNoMask); + + $ifByYearDay = $byYearDay !== null && ( + ( + $i < $dtInfo->yearLength && + !in_array($i + 1, $byYearDay) && + !in_array(-$dtInfo->yearLength + $i, $byYearDay) + ) || + ( + $i >= $dtInfo->yearLength && + !in_array($i + 1 - $dtInfo->yearLength, $byYearDay) && + !in_array(-$dtInfo->nextYearLength + $i - $dtInfo->yearLength, $byYearDay) + ) + ); + + $ifByMonthDay = $byMonthDay !== null && !in_array($dtInfo->mDayMask[$dayOfYear], $byMonthDay); + + // Handle "last day of next month" problem. + if ($fixLastDayOfMonth + && $ifByMonthDay + && $implicitByMonthDay + && $startMonthLength > $dtInfo->monthLength + && $dayOfMonth == $dtInfo->monthLength + && $dayOfMonth < $startMonthLength + && !$numMatched + ) { + $ifByMonthDay = false; + } + + $ifByMonthDayNeg = $byMonthDayNeg !== null + && !in_array($dtInfo->mDayMaskNeg[$dayOfYear], $byMonthDayNeg); + + $ifByDay = $byWeekDay !== null && count($byWeekDay) + && !in_array($dtInfo->wDayMask[$dayOfYear], $byWeekDay); + + $ifWDayMaskRel = $byWeekDayRel !== null && !in_array($dayOfYear, $wDayMaskRel); + + if ($byMonthDay !== null && $byMonthDayNeg !== null) { + if ($ifByMonthDay && $ifByMonthDayNeg) { + unset($daySet[$i]); + } + } elseif ($ifByMonth || $ifByWeekNum || $ifByYearDay || $ifByMonthDay || $ifByMonthDayNeg || $ifByDay || $ifWDayMaskRel) { + unset($daySet[$i]); + } else { + ++$numMatched; + } + } + + if (!empty($bySetPos) && !empty($daySet)) { + $datesAdj = array(); + $tmpDaySet = array_combine($daySet, $daySet); + + foreach ($bySetPos as $setPos) { + if ($setPos < 0) { + $dayPos = floor($setPos / count($timeSet)); + $timePos = DateUtil::pymod($setPos, count($timeSet)); + } else { + $dayPos = floor(($setPos - 1) / count($timeSet)); + $timePos = DateUtil::pymod(($setPos - 1), count($timeSet)); + } + + $tmp = array(); + for ($k = $daySetStart; $k <= $daySetEnd; $k++) { + if (!array_key_exists($k, $tmpDaySet)) { + continue; + } + + $tmp[] = $tmpDaySet[$k]; + } + + if ($dayPos < 0) { + $nextInSet = array_slice($tmp, $dayPos, 1); + if (count($nextInSet) === 0) { + continue; + } + $nextInSet = $nextInSet[0]; + } else { + $nextInSet = isset($tmp[$dayPos]) ? $tmp[$dayPos] : null; + } + + if (null !== $nextInSet) { + /** @var Time $time */ + $time = $timeSet[$timePos]; + + $dtTmp = DateUtil::getDateTimeByDayOfYear($nextInSet, $dt->format('Y'), $start->getTimezone()); + + $dtTmp = $dtTmp->setTime( + $time->hour, + $time->minute, + $time->second + ); + + $datesAdj[] = $dtTmp; + } + } + + foreach ($datesAdj as $dtTmp) { + if (null !== $until && $dtTmp > $until) { + $continue = false; + break; + } + + if ($dtTmp < $start) { + continue; + } + + if ($constraint instanceof ConstraintInterface && !$constraint->test($dtTmp)) { + if (!$countConstraintFailures) { + if ($constraint->stopsTransformer()) { + $continue = false; + break; + } else { + continue; + } + } + } else { + $dates[$total] = $dtTmp; + } + + if (null !== $count) { + --$count; + if ($count <= 0) { + $continue = false; + break; + } + } + + ++$total; + if ($total > $vLimit) { + $continue = false; + break; + } + } + } else { + foreach ($daySet as $dayOfYear) { + $dtTmp = DateUtil::getDateTimeByDayOfYear($dayOfYear, $dt->format('Y'), $start->getTimezone()); + + foreach ($timeSet as $time) { + /** @var Time $time */ + $dtTmp = $dtTmp->setTime( + $time->hour, + $time->minute, + $time->second + ); + + if (null !== $until && $dtTmp > $until) { + $continue = false; + break; + } + + if ($dtTmp < $start) { + continue; + } + + if ($constraint instanceof ConstraintInterface && !$constraint->test($dtTmp)) { + if (!$countConstraintFailures) { + if ($constraint->stopsTransformer()) { + $continue = false; + break; + } else { + continue; + } + } + } else { + $dates[$total] = clone $dtTmp; + } + + if (null !== $count) { + --$count; + if ($count <= 0) { + $continue = false; + break; + } + } + + ++$total; + if ($total > $vLimit) { + $continue = false; + break; + } + } + + if (!$continue) { + break; + } + } + + if ($total > $vLimit) { + $continue = false; + break; + } + } + + switch ($freq) { + case Frequency::YEARLY: + $year += $rule->getInterval(); + $month = $dt->format('n'); + $dt = $dt->setDate($year, $month, 1); + + // Stop an infinite loop w/ a sane limit + ++$iterations; + if ($iterations > 300 && !count($dates)) { + break 2; + } + break; + case Frequency::MONTHLY: + $month += $rule->getInterval(); + if ($month > 12) { + $delta = floor($month / 12); + $mod = DateUtil::pymod($month, 12); + $month = $mod; + $year += $delta; + if ($month == 0) { + $month = 12; + --$year; + } + } + $dt = $dt->setDate($year, $month, 1); + break; + case Frequency::WEEKLY: + if ($weekStart > $dtInfo->dayOfWeek) { + $delta = ($dtInfo->dayOfWeek + 1 + (6 - $weekStart)) * -1 + $rule->getInterval() * 7; + } else { + $delta = ($dtInfo->dayOfWeek - $weekStart) * -1 + $rule->getInterval() * 7; + } + + $dt = $dt->modify("+$delta day"); + $year = $dt->format('Y'); + $month = $dt->format('n'); + break; + case Frequency::DAILY: + $dt = $dt->modify('+'.$rule->getInterval().' day'); + $year = $dt->format('Y'); + $month = $dt->format('n'); + break; + case Frequency::HOURLY: + $dt = $dt->modify('+'.$rule->getInterval().' hours'); + $year = $dt->format('Y'); + $month = $dt->format('n'); + $hour = $dt->format('G'); + break; + case Frequency::MINUTELY: + $dt = $dt->modify('+'.$rule->getInterval().' minutes'); + $year = $dt->format('Y'); + $month = $dt->format('n'); + $hour = $dt->format('G'); + $minute = $dt->format('i'); + break; + case Frequency::SECONDLY: + $dt = $dt->modify('+'.$rule->getInterval().' seconds'); + $year = $dt->format('Y'); + $month = $dt->format('n'); + $hour = $dt->format('G'); + $minute = $dt->format('i'); + $second = $dt->format('s'); + break; + } + } + + /** @var Recurrence[] $recurrences */ + $recurrences = array(); + foreach ($dates as $key => $start) { + /** @var \DateTimeInterface $end */ + $end = clone $start; + + $recurrences[] = new Recurrence($start, $end->add($durationInterval), $key); + } + + $recurrences = $this->handleInclusions($rule->getRDates(), $recurrences); + $recurrences = $this->handleExclusions($rule->getExDates(), $recurrences); + + return new RecurrenceCollection($recurrences); + } + + /** + * @param DateExclusion[] $exclusions + * @param Recurrence[] $recurrences + * + * @return Recurrence[] + */ + protected function handleExclusions(array $exclusions, array $recurrences) + { + foreach ($exclusions as $exclusion) { + $exclusionDate = $exclusion->date->format('Ymd'); + $exclusionTime = $exclusion->date->format('Ymd\THis'); + $exclusionTimezone = $exclusion->date->getTimezone(); + + foreach ($recurrences as $key => $recurrence) { + $recurrenceDate = $recurrence->getStart(); + + if ($recurrenceDate->getTimezone()->getName() !== $exclusionTimezone->getName()) { + $recurrenceDate = clone $recurrenceDate; + $recurrenceDate = $recurrenceDate->setTimezone($exclusionTimezone); + } + + if (!$exclusion->hasTime && $recurrenceDate->format('Ymd') == $exclusionDate) { + unset($recurrences[$key]); + continue; + } + + if ($exclusion->hasTime && $recurrenceDate->format('Ymd\THis') == $exclusionTime) { + unset($recurrences[$key]); + } + } + } + + return array_values($recurrences); + } + + /** + * @param DateInclusion[] $inclusions + * @param Recurrence[] $recurrences + * + * @return Recurrence[] + */ + protected function handleInclusions(array $inclusions, array $recurrences) + { + foreach ($inclusions as $inclusion) { + $recurrence = new Recurrence(clone $inclusion->date, clone $inclusion->date); + $recurrences[] = $recurrence; + } + + return array_values($recurrences); + } +} diff --git a/app/lib/vendor/simshaun/recurr/src/Recurr/Transformer/ArrayTransformerConfig.php b/app/lib/vendor/simshaun/recurr/src/Recurr/Transformer/ArrayTransformerConfig.php new file mode 100644 index 00000000..68350b06 --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/src/Recurr/Transformer/ArrayTransformerConfig.php @@ -0,0 +1,65 @@ +virtualLimit = (int) $virtualLimit; + + return $this; + } + + /** + * Get the virtual limit imposed upon infinitely recurring events. + * + * @return int + */ + public function getVirtualLimit() + { + return $this->virtualLimit; + } + + /** + * By default, January 30 + 1 month results in March 30 because February doesn't have 30 days. + * + * Enabling this fix tells Recurr that +1 month means "last day of next month". + */ + public function enableLastDayOfMonthFix() + { + $this->lastDayOfMonthFix = true; + } + + public function disableLastDayOfMonthFix() + { + $this->lastDayOfMonthFix = false; + } + + /** + * @return boolean + */ + public function isLastDayOfMonthFixEnabled() + { + return $this->lastDayOfMonthFix; + } +} diff --git a/app/lib/vendor/simshaun/recurr/src/Recurr/Transformer/Constraint.php b/app/lib/vendor/simshaun/recurr/src/Recurr/Transformer/Constraint.php new file mode 100644 index 00000000..2a9cf2a5 --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/src/Recurr/Transformer/Constraint.php @@ -0,0 +1,21 @@ +stopsTransformer; + } +} \ No newline at end of file diff --git a/app/lib/vendor/simshaun/recurr/src/Recurr/Transformer/Constraint/AfterConstraint.php b/app/lib/vendor/simshaun/recurr/src/Recurr/Transformer/Constraint/AfterConstraint.php new file mode 100644 index 00000000..3baf9a0e --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/src/Recurr/Transformer/Constraint/AfterConstraint.php @@ -0,0 +1,64 @@ +after = $after; + $this->inc = $inc; + } + + /** + * Passes if $date is after $after + * + * {@inheritdoc} + */ + public function test(\DateTimeInterface $date) + { + if ($this->inc) { + return $date >= $this->after; + } + + return $date > $this->after; + } + + /** + * @return \DateTimeInterface + */ + public function getAfter() + { + return $this->after; + } + + /** + * @return bool + */ + public function isInc() + { + return $this->inc; + } +} diff --git a/app/lib/vendor/simshaun/recurr/src/Recurr/Transformer/Constraint/BeforeConstraint.php b/app/lib/vendor/simshaun/recurr/src/Recurr/Transformer/Constraint/BeforeConstraint.php new file mode 100644 index 00000000..aa94525a --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/src/Recurr/Transformer/Constraint/BeforeConstraint.php @@ -0,0 +1,64 @@ +before = $before; + $this->inc = $inc; + } + + /** + * Passes if $date is before $before + * + * {@inheritdoc} + */ + public function test(\DateTimeInterface $date) + { + if ($this->inc) { + return $date <= $this->before; + } + + return $date < $this->before; + } + + /** + * @return \DateTimeInterface + */ + public function getBefore() + { + return $this->before; + } + + /** + * @return bool + */ + public function isInc() + { + return $this->inc; + } +} diff --git a/app/lib/vendor/simshaun/recurr/src/Recurr/Transformer/Constraint/BetweenConstraint.php b/app/lib/vendor/simshaun/recurr/src/Recurr/Transformer/Constraint/BetweenConstraint.php new file mode 100644 index 00000000..f16d4916 --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/src/Recurr/Transformer/Constraint/BetweenConstraint.php @@ -0,0 +1,81 @@ +after = $after; + $this->before = $before; + $this->inc = $inc; + } + + /** + * Passes if $date is between $after and $before + * + * {@inheritdoc} + */ + public function test(\DateTimeInterface $date) + { + if ($date > $this->before) { + $this->stopsTransformer = true; + } + + if ($this->inc) { + return $date >= $this->after && $date <= $this->before; + } + + return $date > $this->after && $date < $this->before; + } + + /** + * @return \DateTimeInterface + */ + public function getBefore() + { + return $this->before; + } + + /** + * @return \DateTimeInterface + */ + public function getAfter() + { + return $this->after; + } + + /** + * @return bool + */ + public function isInc() + { + return $this->inc; + } +} diff --git a/app/lib/vendor/simshaun/recurr/src/Recurr/Transformer/ConstraintInterface.php b/app/lib/vendor/simshaun/recurr/src/Recurr/Transformer/ConstraintInterface.php new file mode 100644 index 00000000..6879554d --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/src/Recurr/Transformer/ConstraintInterface.php @@ -0,0 +1,25 @@ +translator = $translator ?: new Translator('en'); + } + + public function transform(Rule $rule) + { + $this->fragments = array(); + + switch ($rule->getFreq()) { + case 0: + $this->addYearly($rule); + break; + case 1: + $this->addMonthly($rule); + break; + case 2: + $this->addWeekly($rule); + break; + case 3: + $this->addDaily($rule); + break; + case 4: + $this->addHourly($rule); + break; + case 5: + case 6: + return $this->translator->trans('Unable to fully convert this rrule to text.'); + } + + $until = $rule->getUntil(); + $count = $rule->getCount(); + if ($until instanceof \DateTimeInterface) { + $dateFormatted = $this->translator->trans('day_date', array('date' => $until->format('U'))); + $this->addFragment($this->translator->trans('until %date%', array('date' => $dateFormatted))); + } else if (!empty($count)) { + if ($this->isPlural($count)) { + $this->addFragment($this->translator->trans('for %count% times', array('count' => $count))); + } else { + $this->addFragment($this->translator->trans('for one time')); + } + } + + if (!$this->isFullyConvertible($rule)) { + $this->addFragment($this->translator->trans('(~ approximate)')); + } + + return implode(' ', $this->fragments); + } + + protected function isFullyConvertible(Rule $rule) + { + if ($rule->getFreq() >= 5) { + return false; + } + + $until = $rule->getUntil(); + $count = $rule->getCount(); + if (!empty($until) && !empty($count)) { + return false; + } + + $bySecond = $rule->getBySecond(); + $byMinute = $rule->getByMinute(); + $byHour = $rule->getByHour(); + + if (!empty($bySecond) || !empty($byMinute) || !empty($byHour)) { + return false; + } + + $byWeekNum = $rule->getByWeekNumber(); + $byYearDay = $rule->getByYearDay(); + if ($rule->getFreq() != 0 && (!empty($byWeekNum) || !empty($byYearDay))) { + return false; + } + + return true; + } + + protected function addYearly(Rule $rule) + { + $interval = $rule->getInterval(); + $byMonth = $rule->getByMonth(); + $byMonthDay = $rule->getByMonthDay(); + $byDay = $rule->getByDay(); + $byYearDay = $rule->getByYearDay(); + $byWeekNum = $rule->getByWeekNumber(); + + if (!empty($byMonth) && count($byMonth) > 1 && $interval == 1) { + $this->addFragment($this->translator->trans('every_month_list')); + } else { + $this->addFragment($this->translator->trans($this->isPlural($interval) ? 'every %count% years' : 'every year', array('count' => $interval))); + } + + $hasNoOrOneByMonth = is_null($byMonth) || count($byMonth) <= 1; + if ($hasNoOrOneByMonth && empty($byMonthDay) && empty($byDay) && empty($byYearDay) && empty($byWeekNum)) { + $this->addFragment($this->translator->trans('on')); + $monthNum = (is_array($byMonth) && count($byMonth)) ? $byMonth[0] : $rule->getStartDate()->format('n'); + $this->addFragment( + $this->translator->trans('day_month', array('month' => $monthNum, 'day' => $rule->getStartDate()->format('d'))) + ); + } elseif (!empty($byMonth)) { + if ($interval != 1) { + $this->addFragment($this->translator->trans('in_month')); + } + + $this->addByMonth($rule); + } + + if (!empty($byMonthDay)) { + $this->addByMonthDay($rule); + $this->addFragment($this->translator->trans('of_the_month')); + } else if (!empty($byDay)) { + $this->addByDay($rule); + } + + if (!empty($byYearDay)) { + $this->addFragment($this->translator->trans('on the')); + $this->addFragment($this->getByYearDayAsText($byYearDay)); + $this->addFragment($this->translator->trans('day')); + } + + if (!empty($byWeekNum)) { + $this->addFragment($this->translator->trans('in_week')); + $this->addFragment($this->translator->trans($this->isPlural(count($byWeekNum)) ? 'weeks' : 'week')); + $this->addFragment($this->getByWeekNumberAsText($byWeekNum)); + } + + if (empty($byMonthDay) && empty($byYearDay) && empty($byDay) && !empty($byWeekNum)) { + $this->addDayOfWeek($rule); + } + } + + protected function addMonthly(Rule $rule) + { + $interval = $rule->getInterval(); + $byMonth = $rule->getByMonth(); + + if (!empty($byMonth) && $interval == 1) { + $this->addFragment($this->translator->trans('every_month_list')); + } else { + $this->addFragment($this->translator->trans($this->isPlural($interval) ? 'every %count% months' : 'every month', array('count' => $interval))); + } + + if (!empty($byMonth)) { + if ($interval != 1) { + $this->addFragment($this->translator->trans('in_month')); + } + + $this->addByMonth($rule); + } + + $byMonthDay = $rule->getByMonthDay(); + $byDay = $rule->getByDay(); + if (!empty($byMonthDay)) { + $this->addByMonthDay($rule); + } else if (!empty($byDay)) { + $this->addByDay($rule); + } + } + + protected function addWeekly(Rule $rule) + { + $interval = $rule->getInterval(); + $byMonth = $rule->getByMonth(); + $byMonthDay = $rule->getByMonthDay(); + $byDay = $rule->getByDay(); + + $this->addFragment($this->translator->trans($this->isPlural($interval) ? 'every %count% weeks' : 'every week', array('count' => $interval))); + + if (empty($byMonthDay) && empty($byDay)) { + $this->addDayOfWeek($rule); + } + + if (!empty($byMonth)) { + $this->addFragment($this->translator->trans('in_month')); + $this->addByMonth($rule); + } + + if (!empty($byMonthDay)) { + $this->addByMonthDay($rule); + $this->addFragment($this->translator->trans('of_the_month')); + } else if (!empty($byDay)) { + $this->addByDay($rule); + } + } + + protected function addDaily(Rule $rule) + { + $interval = $rule->getInterval(); + $byMonth = $rule->getByMonth(); + + $this->addFragment($this->translator->trans($this->isPlural($interval) ? 'every %count% days' : 'every day', array('count' => $interval))); + + if (!empty($byMonth)) { + $this->addFragment($this->translator->trans('in_month')); + $this->addByMonth($rule); + } + + $byMonthDay = $rule->getByMonthDay(); + $byDay = $rule->getByDay(); + if (!empty($byMonthDay)) { + $this->addByMonthDay($rule); + $this->addFragment($this->translator->trans('of_the_month')); + } else if (!empty($byDay)) { + $this->addByDay($rule); + } + } + + protected function addHourly(Rule $rule) + { + $interval = $rule->getInterval(); + $byMonth = $rule->getByMonth(); + + $this->addFragment($this->translator->trans($this->isPlural($interval) ? 'every %count% hours' : 'every hour', array('count' => $interval))); + + if (!empty($byMonth)) { + $this->addFragment($this->translator->trans('in_month')); + $this->addByMonth($rule); + } + + $byMonthDay = $rule->getByMonthDay(); + $byDay = $rule->getByDay(); + if (!empty($byMonthDay)) { + $this->addByMonthDay($rule); + $this->addFragment($this->translator->trans('of_the_month')); + } else if (!empty($byDay)) { + $this->addByDay($rule); + } + } + + protected function addByMonth(Rule $rule) + { + $byMonth = $rule->getByMonth(); + + if (empty($byMonth)) { + return; + } + + $this->addFragment($this->getByMonthAsText($byMonth)); + } + + protected function addByMonthDay(Rule $rule) + { + $byMonthDay = $rule->getByMonthDay(); + $byDay = $rule->getByDay(); + + if (!empty($byDay)) { + $this->addFragment($this->translator->trans('on')); + $this->addFragment($this->getByDayAsText($byDay, 'or')); + $this->addFragment($this->translator->trans('the_for_monthday')); + $this->addFragment($this->getByMonthDayAsText($byMonthDay, 'or')); + } else { + $this->addFragment($this->translator->trans('on the')); + $this->addFragment($this->getByMonthDayAsText($byMonthDay, 'and')); + } + } + + protected function addByDay(Rule $rule) + { + $byDay = $rule->getByDay(); + + $this->addFragment($this->translator->trans('on')); + $this->addFragment($this->getByDayAsText($byDay)); + } + + protected function addDayOfWeek(Rule $rule) + { + $this->addFragment($this->translator->trans('on')); + $dayNames = $this->translator->trans('day_names'); + $this->addFragment($dayNames[$rule->getStartDate()->format('w')]); + } + + public function getByMonthAsText($byMonth) + { + if (empty($byMonth)) { + return ''; + } + + if (count($byMonth) > 1) { + sort($byMonth); + } + + $monthNames = $this->translator->trans('month_names'); + $byMonth = array_map( + function ($monthInt) use ($monthNames) { + return $monthNames[$monthInt - 1]; + }, + $byMonth + ); + + return $this->getListStringFromArray($byMonth); + } + + public function getByDayAsText($byDay, $listSeparator = 'and') + { + if (empty($byDay)) { + return ''; + } + + $map = array( + 'SU' => null, + 'MO' => null, + 'TU' => null, + 'WE' => null, + 'TH' => null, + 'FR' => null, + 'SA' => null + ); + + $dayNames = $this->translator->trans('day_names'); + $timestamp = mktime(1, 1, 1, 1, 12, 2014); // A Sunday + foreach (array_keys($map) as $short) { + $long = $dayNames[date('w', $timestamp)]; + $map[$short] = $long; + $timestamp += 86400; + } + + $numOrdinals = 0; + foreach ($byDay as $key => $short) { + $day = strtoupper($short); + $string = ''; + + if (preg_match('/([+-]?)([0-9]*)([A-Z]+)/', $short, $parts)) { + $symbol = $parts[1]; + $nth = $parts[2]; + $day = $parts[3]; + + if (!empty($nth)) { + ++$numOrdinals; + $string .= $this->getOrdinalNumber($symbol == '-' ? -$nth : $nth); + } + } + + if (!isset($map[$day])) { + throw new \RuntimeException("byDay $short could not be transformed"); + } + + if (!empty($string)) { + $string .= ' '; + } + + $byDay[$key] = ltrim($string.$map[$day]); + } + + $output = $numOrdinals ? $this->translator->trans('the_for_weekday') . ' ' : ''; + if ($output == ' ') { + $output = ''; + } + $output .= $this->getListStringFromArray($byDay, $listSeparator); + + return $output; + } + + public function getByMonthDayAsText($byMonthDay, $listSeparator = 'and') + { + if (empty($byMonthDay)) { + return ''; + } + + // sort negative indices in reverse order so we get e.g. 1st, 2nd, 4th, 3rd last, last day + usort($byMonthDay, function ($a, $b) { + if (($a < 0 && $b < 0) || ($a >= 0 && $b >= 0)) { + return $a - $b; + } + + return $b - $a; + }); + + // generate ordinal numbers and insert a "on the" for clarity in the middle if we have both + // positive and negative ordinals. This is to avoid confusing situations like: + // + // monthly on the 1st and 2nd to the last day + // + // which gets clarified to: + // + // monthly on the 1st day and on the 2nd to the last day + $hadPositives = false; + $hadNegatives = false; + foreach ($byMonthDay as $index => $day) { + $prefix = ''; + if ($day >= 0) { + $hadPositives = true; + } + if ($day < 0) { + if ($hadPositives && !$hadNegatives && $listSeparator === 'and') { + $prefix = $this->translator->trans('on the') . ' '; + } + $hadNegatives = true; + } + $byMonthDay[$index] = $prefix . $this->getOrdinalNumber($day, end($byMonthDay) < 0, true); + } + + return $this->getListStringFromArray($byMonthDay, $listSeparator); + } + + public function getByYearDayAsText($byYearDay) + { + if (empty($byYearDay)) { + return ''; + } + + // sort negative indices in reverse order so we get e.g. 1st, 2nd, 4th, 3rd last, last day + usort($byYearDay, function ($a, $b) { + if (($a < 0 && $b < 0) || ($a >= 0 && $b >= 0)) { + return $a - $b; + } + + return $b - $a; + }); + + $byYearDay = array_map( + array($this, 'getOrdinalNumber'), + $byYearDay, + array_fill(0, count($byYearDay), end($byYearDay) < 0) + ); + + return $this->getListStringFromArray($byYearDay); + } + + public function getByWeekNumberAsText($byWeekNum) + { + if (empty($byWeekNum)) { + return ''; + } + + if (count($byWeekNum) > 1) { + sort($byWeekNum); + } + + return $this->getListStringFromArray($byWeekNum); + } + + protected function addFragment($fragment) + { + if ($fragment && $fragment !== ' ') { + $this->fragments[] = $fragment; + } + } + + public function resetFragments() + { + $this->fragments = array(); + } + + protected function isPlural($number) + { + return $number % 100 != 1; + } + + + protected function getOrdinalNumber($number, $hasNegatives = false, $dayInMonth = false) + { + if (!preg_match('{^-?\d+$}D', $number)) { + throw new \RuntimeException('$number must be a whole number'); + } + + return $this->translator->trans('ordinal_number', array('number' => $number, 'has_negatives' => $hasNegatives, 'day_in_month' => $dayInMonth)); + } + + protected function getListStringFromArray($values, $separator = 'and') + { + $separator = $this->translator->trans($separator); + + if (!is_array($values)) { + throw new \RuntimeException('$values must be an array.'); + } + + $numValues = count($values); + + if (!$numValues) { + return ''; + } + + if ($numValues == 1) { + reset($values); + + return current($values); + } + + if ($numValues == 2) { + return implode(" $separator ", $values); + } + + $lastValue = array_pop($values); + $output = implode(', ', $values); + $output .= " $separator ".$lastValue; + + return $output; + } +} diff --git a/app/lib/vendor/simshaun/recurr/src/Recurr/Transformer/Translator.php b/app/lib/vendor/simshaun/recurr/src/Recurr/Transformer/Translator.php new file mode 100644 index 00000000..cf3cb2af --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/src/Recurr/Transformer/Translator.php @@ -0,0 +1,42 @@ +loadLocale($fallbackLocale); + if ($locale !== $fallbackLocale) { + $this->loadLocale($locale); + } + } + + public function loadLocale($locale, $path = null) + { + if (!$path) { + $path = __DIR__ . '/../../../translations/' . $locale . '.php'; + } + if (!file_exists($path)) { + throw new \InvalidArgumentException('Locale '.$locale.' could not be found in '.$path); + } + + $this->data = array_merge($this->data, include $path); + } + + public function trans($string, array $params = array()) + { + $res = $this->data[$string]; + if (is_object($res) && is_callable($res)) { + $res = $res($string, $params); + } + + foreach ($params as $key => $val) { + $res = str_replace('%' . $key . '%', $val, $res); + } + + return $res; + } +} diff --git a/app/lib/vendor/simshaun/recurr/src/Recurr/Transformer/TranslatorInterface.php b/app/lib/vendor/simshaun/recurr/src/Recurr/Transformer/TranslatorInterface.php new file mode 100644 index 00000000..96e77f4b --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/src/Recurr/Transformer/TranslatorInterface.php @@ -0,0 +1,8 @@ + + */ +class Weekday +{ + /** + * Weekday number. + * + * 0 = Sunday + * 1 = Monday + * 2 = Tuesday + * 3 = Wednesday + * 4 = Thursday + * 5 = Friday + * 6 = Saturday + * + * @var string + */ + public $weekday; + + /** @var int nth occurrence of the weekday */ + public $num; + + protected $days = array('MO', 'TU', 'WE', 'TH', 'FR', 'SA', 'SU'); + + /** + * @param int|string $weekday 0-6 or MO..SU + * @param null|int $num + * + * @throws InvalidWeekday + */ + public function __construct($weekday, $num) + { + if (is_numeric($weekday) && $weekday > 6 || $weekday < 0) { + throw new InvalidWeekday('Day is not a valid weekday (0-6)'); + } elseif (!is_numeric($weekday) && !in_array($weekday, $this->days)) { + throw new InvalidWeekday('Day is not a valid weekday (SU, MO, ...)'); + } + + if (!is_numeric($weekday)) { + $weekday = array_search($weekday, $this->days); + } + + $this->weekday = $weekday; + $this->num = $num; + } + + public function __toString() + { + return $this->num . $this->days[$this->weekday]; + } +} diff --git a/app/lib/vendor/simshaun/recurr/translations/da.php b/app/lib/vendor/simshaun/recurr/translations/da.php new file mode 100644 index 00000000..ba4d6b6f --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/translations/da.php @@ -0,0 +1,100 @@ + 'Kunne ikke konvertere denne regel til tekst.', + 'for %count% times' => '%count% gange', + 'for one time' => 'en gang', + '(~ approximate)' => '(~ cirka)', + 'until %date%' => 't.o.m. %date%', // e.g. every year until July 4, 2014 + 'day_date' => function ($str, $params) use ($days, $months) { // outputs a day date, e.g. July 4, 2014 + return date('j', $params['date']) . '. '. $months[date('n', $params['date']) - 1].date(', Y', $params['date']); + }, + 'day_month' => function ($str, $params) use ($days, $months) { // outputs a day month, e.g. July 4 + return $params['day'].'. '.$months[$params['month'] - 1]; + }, + 'day_names' => $days, + 'month_names' => $months, + 'and' => 'og', + 'or' => 'eller', + 'in_month' => 'i', // e.g. weekly in January, May and August + 'in_week' => 'i', // e.g. yearly in week 3 + 'on' => 'hver', // e.g. every day on Tuesday, Wednesday and Friday + 'the_for_monthday' => 'den', // e.g. monthly on Tuesday the 1st + 'the_for_weekday' => 'den', // e.g. monthly on the 4th Monday + 'on the' => 'pÃ¥ den', // e.g. every year on the 1st and 200th day + 'of_the_month' => 'i mÃ¥neden', // e.g. every year on the 2nd or 3rd of the month + 'every %count% years' => 'hvert %count% Ã¥r', + 'every year' => 'Ã¥rligt', + 'every_month_list' => 'hver', // e.g. every January, May and August + 'every %count% months' => 'hver %count% mÃ¥ned', + 'every month' => 'mÃ¥nedsvis', + 'every %count% weeks' => 'hver %count% uge', + 'every week' => 'ugenligt', + 'every %count% days' => 'hver %count% dag', + 'every day' => 'dagligt', + 'last' => 'sidste', // e.g. 2nd last Friday + 'days' => 'dage', + 'day' => 'dag', + 'weeks' => 'uger', + 'week' => 'uge', + // formats a number with a prefix e.g. every year on the 1st and 200th day + // negative numbers should be handled as in '5th to the last' or 'last' + // + // if has_negatives is true in the params, it is good form to add 'day' after + // each number, as in: 'every month on the 5th day or 2nd to the last day' or + // it may be confusing like 'every month on the 5th or 2nd to the last day' + 'ordinal_number' => function ($str, $params) { + $number = $params['number']; + + $ends = array(':e', ':a', ':a', ':e', ':e', ':e', ':e', ':e', ':e', ':e'); + $suffix = ''; + + $isNegative = $number < 0; + + if ($number == -1) { + $abbreviation = 'last'; + } else { + if ($isNegative) { + $number = abs($number); + $suffix = ' to the last'; + } + + if (($number % 100) >= 11 && ($number % 100) <= 13) { + $abbreviation = $number.'.'; + } else { + $abbreviation = $number.$ends[$number % 10]; + } + } + + if (!empty($params['has_negatives'])) { + $suffix .= ' dag'; + } + + return $abbreviation . $suffix; + }, +); \ No newline at end of file diff --git a/app/lib/vendor/simshaun/recurr/translations/de.php b/app/lib/vendor/simshaun/recurr/translations/de.php new file mode 100644 index 00000000..9c836b84 --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/translations/de.php @@ -0,0 +1,116 @@ + 'RRule kann nicht vollständig zu Text konvertiert werden.', + 'for %count% times' => '%count% Mal', + 'for one time' => 'einmal', + '(~ approximate)' => '(~ ungefähr)', + 'until %date%' => 'bis %date%', // e.g. every year until July 4, 2014 + 'day_date' => function ($str, $params) use ($days, $months) { // outputs a day date, e.g. 4. Juli, 2014 + return date('j. ', $params['date']) . $months[date('n', $params['date']) - 1] . date(', Y', $params['date']); + }, + 'day_month' => function ($str, $params) use ($days, $months) { // outputs a day month, e.g. July 4 + return $params['day'].'. '.$months[$params['month'] - 1]; + }, + 'day_names' => $days, + 'month_names' => $months, + 'and' => 'und', + 'or' => 'oder', + 'in_month' => 'im', // e.g. weekly in January, May and August + 'in_week' => 'in', // e.g. yearly in week 3 + 'on' => 'am', // e.g. every day on Tuesday, Wednesday and Friday + 'the_for_monthday' => 'dem', // e.g. monthly on Tuesday the 1st + 'the_for_weekday' => '', // e.g. monthly on the 4th Monday + 'on the' => 'am', // e.g. every year on the 1st and 200th day + 'of_the_month' => 'des Monats', // e.g. every year on the 2nd or 3rd of the month + 'every %count% years' => 'alle %count% Jahre', + 'every year' => 'jährlich', + 'every_month_list' => 'jeden', // e.g. every January, May and August + 'every %count% months' => 'alle %count% Monate', + 'every month' => 'monatlich', + 'every %count% weeks' => 'alle %count% Wochen', + 'every week' => 'wöchentlich', + 'every %count% days' => 'alle %count% Tage', + 'every day' => 'täglich', + 'every %count% hours' => 'alle %count% Stunden', + 'every hour' => 'stündlich', + 'last' => 'letzte', // e.g. 2nd last Friday + 'days' => 'Tage', + 'day' => 'Tag', + 'weeks' => 'Wochen', + 'week' => 'Woche', + 'hours' => 'Stunden', + 'hour' => 'stündlich', + // formats a number with a prefix e.g. every year on the 1st and 200th day + // negative numbers should be handled as in '5th to the last' or 'last' + // + // if has_negatives is true in the params, it is good form to add 'day' after + // each number, as in: 'every month on the 5th day or 2nd to the last day' or + // it may be confusing like 'every month on the 5th or 2nd to the last day' + 'ordinal_number' => function ($str, $params) { + $number = $params['number']; + + $suffix = ''; + $isNegative = $number < 0; + + if ($number == -1) { + $abbreviation = 'letzten'; + } elseif ($number == -2) { + $abbreviation = 'vorletzten'; + } elseif ($number == -3) { + $abbreviation = 'drittletzten'; + } elseif ($number == -4) { + $abbreviation = 'viertletzten'; + } elseif ($number == -5) { + $abbreviation = 'fünftletzten'; + } elseif ($number == -6) { + $abbreviation = 'sechstletzten'; + } elseif ($number == -7) { + $abbreviation = 'siebtletzten'; + } elseif ($number == -8) { + $abbreviation = 'achtletzten'; + } elseif ($number == -9) { + $abbreviation = 'neuntletzten'; + } elseif ($number == -10) { + $abbreviation = 'zehntletzten'; + } elseif ($number == -11) { + $abbreviation = 'elftletzten'; + } elseif ($isNegative) { + $number = abs($number); + $abbreviation = $number . 't letzten'; + } else { + $abbreviation = $number . '.'; + } + + if (!empty($params['has_negatives']) && $isNegative) { + $suffix .= ' Tag'; + } + + return $abbreviation . $suffix; + }, +); diff --git a/app/lib/vendor/simshaun/recurr/translations/el.php b/app/lib/vendor/simshaun/recurr/translations/el.php new file mode 100644 index 00000000..dc8c3449 --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/translations/el.php @@ -0,0 +1,110 @@ + 'Αδυναμία πλήρους μετατροπής αυτού του κανόνα rrule σε κείμενο.', + 'for %count% times' => 'για %count% φορές', + 'for one time' => 'για μία φορά', + '(~ approximate)' => '(~ κατά προσέγγιση)', + 'until %date%' => 'μέχρι %date%', // e.g. every year until July 4, 2014 + 'day_date' => function ($str, $params) use ($days, $months_genitive) { // outputs a day date, e.g. 4 Ιουλίου 2014 + return date('j', $params['date']) . ' ' . $months_genitive[date('n', $params['date']) - 1] . ' '. date('Y', $params['date']); + }, + 'day_month' => function ($str, $params) use ($days, $months_genitive) { // outputs a day month, e.g. 4 Ιουλίου + return $params['day'] . ' ' . $months_genitive[$params['month'] - 1]; + }, + 'day_names' => $days, + 'month_names' => $months, + 'and' => 'και', + 'or' => 'ή', + 'in_month' => 'τον', // e.g. weekly in January, May and August + 'in_week' => 'την', // e.g. yearly in week 3 + 'on' => 'την', // e.g. every day on Tuesday, Wednesday and Friday + 'the_for_monthday' => 'την', // e.g. monthly on Tuesday the 1st + 'the_for_weekday' => 'την', // e.g. monthly on the 4th Monday + 'on the' => 'την', // e.g. every year on the 1st and 200th day + 'of_the_month' => 'του μήνα', // e.g. every year on the 2nd or 3rd of the month + 'every %count% years' => 'κάθε %count% χρόνια', + 'every year' => 'ετήσια', + 'every_month_list' => 'κάθε', // e.g. every January, May and August + 'every %count% months' => 'κάθε %count% μήνες', + 'every month' => 'μηνιαία', + 'every %count% weeks' => 'κάθε %count% εβδομάδες', + 'every week' => 'εβδομαδιαία', + 'every %count% days' => 'κάθε %count% ημέρες', + 'every day' => 'καθημερινά', + 'last' => 'τελευταία', // e.g. 2nd last Friday + 'days' => 'ημέρες', + 'day' => 'ημέρα', + 'weeks' => 'εβδομάδες', + 'week' => 'εβδομάδα', + // formats a number with a prefix e.g. every year on the 1st and 200th day + // negative numbers should be handled as in '5th to the last' or 'last' + // + // if has_negatives is true in the params, it is good form to add 'day' after + // each number, as in: 'every month on the 5th day or 2nd to the last day' or + // it may be confusing like 'every month on the 5th or 2nd to the last day' + 'ordinal_number' => function ($str, $params) { + $number = $params['number']; + + $ends = 'η'; + $suffix = ''; + + $isNegative = $number < 0; + + if ($number == -1) { + $abbreviation = 'τελευταία'; + } else { + if ($isNegative) { + $number = abs($number); + $suffix = ' μέχρι την τελευταία'; + } + + $abbreviation = $number . $ends; + } + + if (!empty($params['has_negatives'])) { + $suffix .= ' ημέρα'; + } + + return $abbreviation . $suffix; + }, +); diff --git a/app/lib/vendor/simshaun/recurr/translations/en.php b/app/lib/vendor/simshaun/recurr/translations/en.php new file mode 100644 index 00000000..a7c1276b --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/translations/en.php @@ -0,0 +1,104 @@ + 'Unable to fully convert this rrule to text.', + 'for %count% times' => 'for %count% times', + 'for one time' => 'once', + '(~ approximate)' => '(~ approximate)', + 'until %date%' => 'until %date%', // e.g. every year until July 4, 2014 + 'day_date' => function ($str, $params) use ($days, $months) { // outputs a day date, e.g. July 4, 2014 + return $months[date('n', $params['date']) - 1] . ' '. date('j, Y', $params['date']); + }, + 'day_month' => function ($str, $params) use ($days, $months) { // outputs a day month, e.g. July 4 + return $months[$params['month'] - 1] . ' '. $params['day']; + }, + 'day_names' => $days, + 'month_names' => $months, + 'and' => 'and', + 'or' => 'or', + 'in_month' => 'in', // e.g. weekly in January, May and August + 'in_week' => 'in', // e.g. yearly in week 3 + 'on' => 'on', // e.g. every day on Tuesday, Wednesday and Friday + 'the_for_monthday' => 'the', // e.g. monthly on Tuesday the 1st + 'the_for_weekday' => 'the', // e.g. monthly on the 4th Monday + 'on the' => 'on the', // e.g. every year on the 1st and 200th day + 'of_the_month' => 'of the month', // e.g. every year on the 2nd or 3rd of the month + 'every %count% years' => 'every %count% years', + 'every year' => 'yearly', + 'every_month_list' => 'every', // e.g. every January, May and August + 'every %count% months' => 'every %count% months', + 'every month' => 'monthly', + 'every %count% weeks' => 'every %count% weeks', + 'every week' => 'weekly', + 'every %count% days' => 'every %count% days', + 'every day' => 'daily', + 'every %count% hours' => 'every %count% hours', + 'every hour' => 'hourly', + 'last' => 'last', // e.g. 2nd last Friday + 'days' => 'days', + 'day' => 'day', + 'weeks' => 'weeks', + 'week' => 'week', + 'hours' => 'hours', + 'hour' => 'hour', + // formats a number with a prefix e.g. every year on the 1st and 200th day + // negative numbers should be handled as in '5th to the last' or 'last' + // + // if has_negatives is true in the params, it is good form to add 'day' after + // each number, as in: 'every month on the 5th day or 2nd to the last day' or + // it may be confusing like 'every month on the 5th or 2nd to the last day' + 'ordinal_number' => function ($str, $params) { + $number = $params['number']; + + $ends = array('th', 'st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th'); + $suffix = ''; + + $isNegative = $number < 0; + + if ($number == -1) { + $abbreviation = 'last'; + } else { + if ($isNegative) { + $number = abs($number); + $suffix = ' to the last'; + } + + if (($number % 100) >= 11 && ($number % 100) <= 13) { + $abbreviation = $number.'th'; + } else { + $abbreviation = $number.$ends[$number % 10]; + } + } + + if (!empty($params['has_negatives'])) { + $suffix .= ' day'; + } + + return $abbreviation . $suffix; + }, +); diff --git a/app/lib/vendor/simshaun/recurr/translations/es.php b/app/lib/vendor/simshaun/recurr/translations/es.php new file mode 100644 index 00000000..991ad1d6 --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/translations/es.php @@ -0,0 +1,100 @@ + 'No se puede convertir completamente este RRULE al texto.', + 'for %count% times' => 'para %count% veces', + 'for one time' => 'por una vez', + '(~ approximate)' => '(~ aproximado)', + 'until %date%' => 'hasta %date%', // e.g. every year until July 4, 2014 + 'day_date' => function ($str, $params) use ($days, $months) { // outputs a day date, e.g. July 4, 2014 + return $months[date('n', $params['date']) - 1] . ' '. date('j, Y', $params['date']); + }, + 'day_month' => function ($str, $params) use ($days, $months) { // outputs a day month, e.g. July 4 + return $months[$params['month'] - 1] . ' '. $params['day']; + }, + 'day_names' => $days, + 'month_names' => $months, + 'and' => 'y', + 'or' => 'o', + 'in_month' => 'en', // e.g. weekly in January, May and August + 'in_week' => 'en', // e.g. yearly in week 3 + 'on' => 'en', // e.g. every day on Tuesday, Wednesday and Friday + 'the_for_monthday' => 'el', // e.g. monthly on Tuesday the 1st + 'the_for_weekday' => 'en el', // e.g. monthly on the 4th Monday + 'on the' => 'en el', // e.g. every year on the 1st and 200th day + 'of_the_month' => 'del mes', // e.g. every year on the 2nd or 3rd of the month + 'every %count% years' => 'cada %count% años', + 'every year' => 'anual', + 'every_month_list' => 'cada', // e.g. every January, May and August + 'every %count% months' => 'cada %count% meses', + 'every month' => 'mensual', + 'every %count% weeks' => 'cada %count% semanas', + 'every week' => 'cada semana', + 'every %count% days' => 'cada %count% días', + 'every day' => 'diariamente', + 'last' => 'pasado', // e.g. 2nd last Friday + 'days' => 'día', + 'day' => 'el día', + 'weeks' => 'semanas', + 'week' => 'semana', + // formats a number with a prefix e.g. every year on the 1st and 200th day + // negative numbers should be handled as in '5th to the last' or 'last' + // + // if has_negatives is true in the params, it is good form to add 'day' after + // each number, as in: 'every month on the 5th day or 2nd to the last day' or + // it may be confusing like 'every month on the 5th or 2nd to the last day' + 'ordinal_number' => function ($str, $params) { + $number = $params['number']; + + $ends = array('a', 'a', 'nd', 'a', 'a', 'a', 'a', 'a', 'a', 'a'); + $suffix = ''; + + $isNegative = $number < 0; + + if ($number == -1) { + $abbreviation = 'último'; + } else { + if ($isNegative) { + $number = abs($number); + $suffix = ' a la última'; + } + + if (($number % 100) >= 11 && ($number % 100) <= 13) { + $abbreviation = $number.'a'; + } else { + $abbreviation = $number.$ends[$number % 10]; + } + } + + if (!empty($params['has_negatives'])) { + $suffix .= ' día'; + } + + return $abbreviation . $suffix; + }, +); diff --git a/app/lib/vendor/simshaun/recurr/translations/eu.php b/app/lib/vendor/simshaun/recurr/translations/eu.php new file mode 100644 index 00000000..1c3adba1 --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/translations/eu.php @@ -0,0 +1,43 @@ + 'Ezin izan da rrule testura osoki bihurtu.', + 'for %count% times' => '%count% aldiz', + 'for %count% time' => '%count% aldia', + '(~ approximate)' => '(~ inguru)', + 'until %date%' => '%date% arte', // e.g. every year until July 4, 2014 + 'day_date' => defined('PHP_WINDOWS_VERSION_BUILD') ? '%B %#d, %Y' : '%B %e, %Y', + 'and' => 'eta', + 'or' => 'edo', + 'in' => 'hilabete hauetan:', // e.g. every week in January, May and August + 'on' => 'egun hauetan:', // e.g. every day on Tuesday, Wednesday and Friday + 'the' => '', + 'on the' => '', // e.g. every year on the 1st and 200th day + 'every %count% years' => '%count% urtero', + 'every year' => 'urtero', + 'every_month_list' => 'hilabete hauetan', // e.g. every January, May and August + 'every %count% months' => '%count% hilabetero', + 'every month' => 'hilabetero', + 'every %count% weeks' => '%count% astero', + 'every week' => 'astero', + 'every %count% days' => '%count% egunero', + 'every day' => 'egunero', + 'last' => 'azken', // e.g. 2nd last Friday + 'days' => 'egun', + 'day' => 'egun', + 'weeks' => 'aste', + 'week' => 'aste', + 'ordinal_number' => function ($str, $params) { // formats a number with a prefix e.g. every year on the 1st and 200th day + $number = $params['number']; + + $ends = array('garren', 'go', 'garren', 'garren', 'garren', 'garren', 'garren', 'garren', 'garren', 'garren'); + + if (($number % 100) >= 11 && ($number % 100) <= 13) { + $abbreviation = $number.'garren'; + } else { + $abbreviation = $number.$ends[$number % 10]; + } + + return $abbreviation; + }, +); diff --git a/app/lib/vendor/simshaun/recurr/translations/fr.php b/app/lib/vendor/simshaun/recurr/translations/fr.php new file mode 100644 index 00000000..6bc44a73 --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/translations/fr.php @@ -0,0 +1,103 @@ + 'Cette règle de récurrence n\'a pas pu être convertie en texte.', + 'for %count% times' => '%count% fois', + 'for one time' => 'une fois', + '(~ approximate)' => '(~ approximation)', + 'until %date%' => 'jusqu\'au %date%', // e.g. every year until July 4, 2014 + 'day_date' => function ($str, $params) use ($days, $months) { // outputs a day date, e.g. 4 juillet, 2014 + return date('j ', $params['date']) . $months[date('n', $params['date']) - 1] . date(', Y', $params['date']); + }, + 'day_month' => function ($str, $params) use ($days, $months) { // outputs a day month, e.g. July 4 + return $params['day'].' '.$months[$params['month'] - 1]; + }, + 'day_names' => $days, + 'month_names' => $months, + 'and' => 'et', + 'or' => 'ou', + 'in_month' => 'en', // e.g. weekly in January, May and August + 'in_week' => 'en', // e.g. yearly in week 3 + 'on' => 'le', // e.g. every day on Tuesday, Wednesday and Friday + 'the_for_monthday' => 'le', // e.g. monthly on Tuesday the 1st + 'the_for_weekday' => '', // e.g. monthly on the 4th Monday + 'on the' => 'le', // e.g. every year on the 1st and 200th day + 'of_the_month' => 'du mois', // e.g. every year on the 2nd or 3rd of the month + 'every %count% years' => 'tous les %count% ans', + 'every year' => 'chaque année', + 'every_month_list' => 'chaque', // e.g. every January, May and August + 'every %count% months' => 'tous les %count% mois', + 'every month' => 'chaque mois', + 'every %count% weeks' => 'toutes les %count% semaines', + 'every week' => 'chaque semaine', + 'every %count% days' => 'tous les %count% jours', + 'every day' => 'chaque jour', + 'every %count% hours' => 'toutes les %count% heures', + 'every hour' => 'chaque heure', + 'last' => 'dernier', // e.g. 2nd last Friday + 'days' => 'jours', + 'day' => 'jour', + 'weeks' => 'semaines', + 'week' => 'semaine', + 'hours' => 'heures', + 'hour' => 'heure', + // formats a number with a prefix e.g. every year on the 1st and 200th day + // negative numbers should be handled as in '5th to the last' or 'last' + // + // if has_negatives is true in the params, it is good form to add 'day' after + // each number, as in: 'every month on the 5th day or 2nd to the last day' or + // it may be confusing like 'every month on the 5th or 2nd to the last day' + 'ordinal_number' => function ($str, $params) { + $number = $params['number']; + + $suffix = ''; + $isNegative = $number < 0; + + if ($number == -1) { + $abbreviation = 'dernier'; + } elseif ($number == -2) { + $abbreviation = 'avant dernier'; + } elseif ($isNegative) { + $number = abs($number); + $abbreviation = $number . 'ème au dernier'; + } elseif ($number == 1 && (!$params['day_in_month'])) { + $abbreviation = $number . 'er'; + } else if (!$params['day_in_month']) { + $abbreviation = $number . 'ème'; + } + else { + $abbreviation = $number; + } + + if (!empty($params['has_negatives'])) { + $suffix .= ' jour'; + } + + return $abbreviation . $suffix; + }, +); diff --git a/app/lib/vendor/simshaun/recurr/translations/it.php b/app/lib/vendor/simshaun/recurr/translations/it.php new file mode 100644 index 00000000..9f4d4c01 --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/translations/it.php @@ -0,0 +1,116 @@ + 'Non è possibile convertire questo rrule in testo.', + 'for %count% times' => 'per %count% volte', + 'for one time' => 'per una volta', + '(~ approximate)' => '(~ approssimato)', + 'until %date%' => 'fino al %date%', // e.g. every year until July 4, 2014 + 'day_date' => function ($str, $params) use ($days, $months) { // outputs a day date, e.g. 4 luglio, 2014 + return date('j ', $params['date']) . $months[date('n', $params['date']) - 1] . date(', Y', $params['date']); + }, + 'day_month' => function ($str, $params) use ($days, $months) { // outputs a day month, e.g. July 4 + return $params['day'].' '.$months[$params['month'] - 1]; + }, + 'day_names' => $days, + 'month_names' => $months, + 'and' => 'e', + 'or' => 'o', + 'in_month' => 'in', // e.g. weekly in January, May and August + 'in_week' => 'in', // e.g. yearly in week 3 + 'on' => 'il', // e.g. every day on Tuesday, Wednesday and Friday + 'the_for_monthday' => 'il', // e.g. monthly on Tuesday the 1st + 'the_for_weekday' => 'il', // e.g. monthly on the 4th Monday + 'on the' => 'il', // e.g. every year on the 1st and 200th day + 'of_the_month' => 'del mese', // e.g. every year on the 2nd or 3rd of the month + 'every %count% years' => 'ogni %count% anni', + 'every year' => 'ogni anno', + 'every_month_list' => 'ogni', // e.g. every January, May and August + 'every %count% months' => 'ogni %count% mesi', + 'every month' => 'ogni mese', + 'every %count% weeks' => 'ogni %count% settimane', + 'every week' => 'ogni settimana', + 'every %count% days' => 'ogni %count% giorni', + 'every day' => 'ogni giorno', + 'every %count% hours' => 'ogni %count% ore', + 'every hour' => 'ogni ora', + 'last' => 'scorso', // e.g. 2nd last Friday + 'days' => 'giorni', + 'day' => 'giorno', + 'weeks' => 'settimane', + 'week' => 'settimana', + 'hours' => 'ore', + 'hour' => 'ora', + // formats a number with a prefix e.g. every year on the 1st and 200th day + // negative numbers should be handled as in '5th to the last' or 'last' + // + // if has_negatives is true in the params, it is good form to add 'day' after + // each number, as in: 'every month on the 5th day or 2nd to the last day' or + // it may be confusing like 'every month on the 5th or 2nd to the last day' + 'ordinal_number' => function ($str, $params) { + $number = $params['number']; + + $suffix = ''; + $isNegative = $number < 0; + + if ($number == -1) { + $abbreviation = 'ultimo'; + } elseif ($number == -2) { + $abbreviation = 'penultimo'; + } elseif ($number == -3) { + $abbreviation = 'terzultimo'; + } elseif ($number == -4) { + $abbreviation = 'quarto ultimo'; + } elseif ($number == -5) { + $abbreviation = 'quinta ultimo'; + } elseif ($number == -6) { + $abbreviation = 'sesto ultimo'; + } elseif ($number == -7) { + $abbreviation = 'settimo ultimo'; + } elseif ($number == -8) { + $abbreviation = 'otto ultimo'; + } elseif ($number == -9) { + $abbreviation = 'nono ultimo'; + } elseif ($number == -10) { + $abbreviation = 'decimo ultimo'; + } elseif ($number == -11) { + $abbreviation = 'undici ultimo'; + } elseif ($isNegative) { + $number = abs($number); + $abbreviation = $number . ' ultimo'; + } else { + $abbreviation = $number; + } + + if (!empty($params['has_negatives'])) { + $suffix .= ' giorno'; + } + + return $abbreviation . $suffix; + }, +); diff --git a/app/lib/vendor/simshaun/recurr/translations/nl.php b/app/lib/vendor/simshaun/recurr/translations/nl.php new file mode 100644 index 00000000..77b2718c --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/translations/nl.php @@ -0,0 +1,100 @@ + 'Unable to fully convert this rrule to text.', + 'for %count% times' => 'voor %count% keer', + 'for one time' => 'eenmalig', + '(~ approximate)' => '(~ ongeveer)', + 'until %date%' => 'tot en met %date%', // e.g. every year until July 4, 2014 + 'day_date' => function ($str, $params) use ($days, $months) { // outputs a day date, e.g. July 4, 2014 + return date('j', $params['date']).' '.$months[date('n', $params['date']) - 1] . ' '. date('Y', $params['date']); + }, + 'day_month' => function ($str, $params) use ($days, $months) { // outputs a day month, e.g. July 4 + return $params['day'].' '.$months[$params['month'] - 1]; + }, + 'day_names' => $days, + 'month_names' => $months, + 'and' => 'en', + 'or' => 'of', + 'in_month' => 'op', // e.g. weekly in January, May and August + 'in_week' => 'op', // e.g. yearly in week 3 + 'on' => 'op', // e.g. every day on Tuesday, Wednesday and Friday + 'the_for_monthday' => 'de', // e.g. monthly on Tuesday the 1st + 'the_for_weekday' => 'de', // e.g. monthly on the 4th Monday + 'on the' => 'op de', // e.g. every year on the 1st and 200th day + 'of_the_month' => 'van de maand', // e.g. every year on the 2nd or 3rd of the month + 'every %count% years' => 'elke %count% jaar', + 'every year' => 'jaarlijks', + 'every_month_list' => 'elke', // e.g. every January, May and August + 'every %count% months' => 'elke %count% maanden', + 'every month' => 'maandelijks', + 'every %count% weeks' => 'elke %count% weken', + 'every week' => 'wekelijks', + 'every %count% days' => 'elke %count% dagen', + 'every day' => 'dagelijks', + 'last' => 'laatste', // e.g. 2nd last Friday + 'days' => 'dagen', + 'day' => 'dag', + 'weeks' => 'weken', + 'week' => 'week', + // formats a number with a prefix e.g. every year on the 1st and 200th day + // negative numbers should be handled as in '5th to the last' or 'last' + // + // if has_negatives is true in the params, it is good form to add 'day' after + // each number, as in: 'every month on the 5th day or 2nd to the last day' or + // it may be confusing like 'every month on the 5th or 2nd to the last day' + 'ordinal_number' => function ($str, $params) { + $number = $params['number']; + + $ends = array('ste', 'de', 'de', 'de', 'de', 'de', 'de', 'de', 'de', 'de'); + $suffix = ''; + + $isNegative = $number < 0; + + if ($number == -1) { + $abbreviation = 'laatste'; + } else { + if ($isNegative) { + $number = abs($number); + $suffix = ' na laatste'; + } + + if (($number % 100) >= 11 && ($number % 100) <= 13) { + $abbreviation = $number.'ste'; + } else { + $abbreviation = $number.$ends[$number % 10]; + } + } + + if (!empty($params['has_negatives'])) { + $suffix .= ' dag'; + } + + return $abbreviation . $suffix; + }, +); diff --git a/app/lib/vendor/simshaun/recurr/translations/no.php b/app/lib/vendor/simshaun/recurr/translations/no.php new file mode 100644 index 00000000..e7b5c950 --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/translations/no.php @@ -0,0 +1,100 @@ + 'Kunne ikke konvertere rrule til tekst.', + 'for %count% times' => '%count% ganger', + 'for one time' => 'en gang', + '(~ approximate)' => '(~ omtrent)', + 'until %date%' => 'frem til %date%', // e.g. every year until July 4, 2014 + 'day_date' => function ($str, $params) use ($days, $months) { // outputs a day date, e.g. July 4, 2014 + return $months[date('n', $params['date']) - 1] . ' '. date('j, Y', $params['date']); + }, + 'day_month' => function ($str, $params) use ($days, $months) { // outputs a day month, e.g. July 4 + return $months[$params['month'] - 1] . ' '. $params['day']; + }, + 'day_names' => $days, + 'month_names' => $months, + 'and' => 'og', + 'or' => 'eller', + 'in_month' => 'i', // e.g. weekly in January, May and August + 'in_week' => 'i', // e.g. yearly in week 3 + 'on' => 'på', // e.g. every day on Tuesday, Wednesday and Friday + 'the_for_monthday' => 'den', // e.g. monthly on Tuesday the 1st + 'the_for_weekday' => 'den', // e.g. monthly on the 4th Monday + 'on the' => 'på den', // e.g. every year on the 1st and 200th day + 'of_the_month' => 'i måneden', // e.g. every year on the 2nd or 3rd of the month + 'every %count% years' => 'hvert %count% år', + 'every year' => 'årlig', + 'every_month_list' => 'hver', // e.g. every January, May and August + 'every %count% months' => 'hver %count% måned', + 'every month' => 'månedlig', + 'every %count% weeks' => 'hver %count% uke', + 'every week' => 'ukentlig', + 'every %count% days' => 'hver %count% dag', + 'every day' => 'daglig', + 'last' => 'siste', // e.g. 2nd last Friday + 'days' => 'dager', + 'day' => 'dag', + 'weeks' => 'uker', + 'week' => 'uke', + // formats a number with a prefix e.g. every year on the 1st and 200th day + // negative numbers should be handled as in '5th to the last' or 'last' + // + // if has_negatives is true in the params, it is good form to add 'day' after + // each number, as in: 'every month on the 5th day or 2nd to the last day' or + // it may be confusing like 'every month on the 5th or 2nd to the last day' + 'ordinal_number' => function ($str, $params) { + $number = $params['number']; + + $ends = array('th', 'st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th'); + $suffix = ''; + + $isNegative = $number < 0; + + if ($number == -1) { + $abbreviation = 'sist'; + } else { + if ($isNegative) { + $number = abs($number); + $suffix = ' til den siste'; + } + + if (($number % 100) >= 11 && ($number % 100) <= 13) { + $abbreviation = $number.'th'; + } else { + $abbreviation = $number.$ends[$number % 10]; + } + } + + if (!empty($params['has_negatives'])) { + $suffix .= ' dag'; + } + + return $abbreviation . $suffix; + }, +); diff --git a/app/lib/vendor/simshaun/recurr/translations/pt-br.php b/app/lib/vendor/simshaun/recurr/translations/pt-br.php new file mode 100644 index 00000000..b92b5dc3 --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/translations/pt-br.php @@ -0,0 +1,87 @@ + 'Não foi possível converter esta regra para texto.', + 'for %count% times' => 'por %count% vezes', + 'for one time' => 'uma vez', + '(~ approximate)' => '(~ approximado)', + 'until %date%' => 'até %date%', // e.g. every year until July 4, 2014 + 'day_date' => function ($str, $params) use ($days, $months) { // outputs a day date, e.g. July 4, 2014 + return date('j', $params['date']) . ' de ' . $months[date('n', $params['date']) - 1] . ' de ' . date('Y', $params['date']); + }, + 'day_month' => function ($str, $params) use ($days, $months) { // outputs a day month, e.g. July 4 + return $params['day'].' de '.$months[$params['month'] - 1]; + }, + 'day_names' => $days, + 'month_names' => $months, + 'and' => 'e', + 'or' => 'ou', + 'in_month' => 'em', // e.g. weekly in January, May and August + 'in_week' => 'na', // e.g. yearly in week 3 + 'on' => 'à', // e.g. every day on Tuesday, Wednesday and Friday + 'the_for_monthday' => 'o', // e.g. monthly on Tuesday the 1st + 'the_for_weekday' => 'o', // e.g. monthly on the 4th Monday + 'on the' => 'no', // e.g. every year on the 1st and 200th day + 'of_the_month' => 'do mês', // e.g. every year on the 2nd or 3rd of the month + 'every %count% years' => 'a cada %count% anos', + 'every year' => 'anualmente', + 'every_month_list' => 'sempre em', // e.g. every January, May and August + 'every %count% months' => 'a cada %count% meses', + 'every month' => 'mensalmente', + 'every %count% weeks' => 'a cada %count% semanas', + 'every week' => 'semanalmente', + 'every %count% days' => 'a cada %count% dias', + 'every day' => 'diariamente', + 'last' => 'último', // e.g. 2nd last Friday + 'days' => 'dias', + 'day' => 'dia', + 'weeks' => 'semanas', + 'week' => 'semana', + // formats a number with a prefix e.g. every year on the 1st and 200th day + // negative numbers should be handled as in '5th to the last' or 'last' + // + // if has_negatives is true in the params, it is good form to add 'day' after + // each number, as in: 'every month on the 5th day or 2nd to the last day' or + // it may be confusing like 'every month on the 5th or 2nd to the last day' + 'ordinal_number' => function ($str, $params) { + $number = $params['number']; + + $abbreviation = $number.'°'; + $isNegative = $number < 0; + if ($isNegative) { + $abbreviation = $abbreviation.' último'; + } + + $suffix = ''; + if (!empty($params['has_negatives'])) { + $suffix .= ' dia'; + } + + return $abbreviation . $suffix; + }, +); diff --git a/app/lib/vendor/simshaun/recurr/translations/sv.php b/app/lib/vendor/simshaun/recurr/translations/sv.php new file mode 100644 index 00000000..0dafeaed --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/translations/sv.php @@ -0,0 +1,100 @@ + 'Kunde inte konvertera denna rrule till text.', + 'for %count% times' => '%count% gÃ¥nger', + 'for one time' => 'en gÃ¥ng', + '(~ approximate)' => '(~ ungefärlig)', + 'until %date%' => 't.o.m. %date%', // e.g. every year until July 4, 2014 + 'day_date' => function ($str, $params) use ($days, $months) { // outputs a day date, e.g. July 4, 2014 + return $months[date('n', $params['date']) - 1] . ' '. date('j, Y', $params['date']); + }, + 'day_month' => function ($str, $params) use ($days, $months) { // outputs a day month, e.g. July 4 + return $months[$params['month'] - 1].' '.$params['day']; + }, + 'day_names' => $days, + 'month_names' => $months, + 'and' => 'och', + 'or' => 'eller', + 'in_month' => 'i', // e.g. weekly in January, May and August + 'in_week' => 'i', // e.g. yearly in week 3 + 'on' => 'pÃ¥', // e.g. every day on Tuesday, Wednesday and Friday + 'the_for_monthday' => 'den', // e.g. monthly on Tuesday the 1st + 'the_for_weekday' => 'den', // e.g. monthly on the 4th Monday + 'on the' => 'pÃ¥ den', // e.g. every year on the 1st and 200th day + 'of_the_month' => 'i mÃ¥naden', // e.g. every year on the 2nd or 3rd of the month + 'every %count% years' => 'varje %count% Ã¥r', + 'every year' => 'Ã¥rligen', + 'every_month_list' => 'varje', // e.g. every January, May and August + 'every %count% months' => 'varje %count% mÃ¥nad', + 'every month' => 'mÃ¥nadsvis', + 'every %count% weeks' => 'varje %count% vecka', + 'every week' => 'veckovis', + 'every %count% days' => 'varje %count% dag', + 'every day' => 'dagligen', + 'last' => 'sista', // e.g. 2nd last Friday + 'days' => 'dagar', + 'day' => 'dag', + 'weeks' => 'veckor', + 'week' => 'vecka', + // formats a number with a prefix e.g. every year on the 1st and 200th day + // negative numbers should be handled as in '5th to the last' or 'last' + // + // if has_negatives is true in the params, it is good form to add 'day' after + // each number, as in: 'every month on the 5th day or 2nd to the last day' or + // it may be confusing like 'every month on the 5th or 2nd to the last day' + 'ordinal_number' => function ($str, $params) { + $number = $params['number']; + + $ends = array(':e', ':a', ':a', ':e', ':e', ':e', ':e', ':e', ':e', ':e'); + $suffix = ''; + + $isNegative = $number < 0; + + if ($number == -1) { + $abbreviation = 'last'; + } else { + if ($isNegative) { + $number = abs($number); + $suffix = ' to the last'; + } + + if (($number % 100) >= 11 && ($number % 100) <= 13) { + $abbreviation = $number.'th'; + } else { + $abbreviation = $number.$ends[$number % 10]; + } + } + + if (!empty($params['has_negatives'])) { + $suffix .= ' dag'; + } + + return $abbreviation . $suffix; + }, +); diff --git a/app/lib/vendor/simshaun/recurr/translations/tr.php b/app/lib/vendor/simshaun/recurr/translations/tr.php new file mode 100644 index 00000000..33d5295a --- /dev/null +++ b/app/lib/vendor/simshaun/recurr/translations/tr.php @@ -0,0 +1,100 @@ + 'Bu rrule tam metne dönüştürülemiyor.', + 'for %count% times' => '%count% kez', + 'for one time' => 'bir kere', + '(~ approximate)' => '(~ yaklaşık)', + 'until %date%' => 'kadar %date%', // e.g. 4 Temmuz 2014 e kadar her yıl + 'day_date' => function ($str, $params) use ($days, $months) { // tarih çıktıları, e.g. Temmuz 4, 2014 + return $months[date('n', $params['date']) - 1] . ' '. date('j, Y', $params['date']); + }, + 'day_month' => function ($str, $params) use ($days, $months) { // outputs a day month, e.g. July 4 + return $months[$params['month'] - 1].' '.$params['day']; + }, + 'day_names' => $days, + 'month_names' => $months, + 'and' => 've', + 'or' => 'veya', + 'in_month' => 'içinde', // e.g. Ocak, Mayıs ve Ağustos'ta haftalık + 'in_week' => 'içinde', // e.g. yıllık haftada 3 + 'on' => 'on', // e.g. her Salı, Çarşamba ve Cuma günü + 'the_for_monthday' => 'the', // e.g. monthly on Tuesday the 1st + 'the_for_weekday' => 'the', // e.g. monthly on the 4th Monday + 'on the' => 'üzerinde', // e.g. her yıl 1. ve 200. günde + 'of_the_month' => 'ayın', // e.g. her yıl 2. ve 3. ayın + 'every %count% years' => 'every %count% years', + 'every year' => 'yıllık', + 'every_month_list' => 'her', // e.g. her Ocak, Mayıs ve Ağustos + 'every %count% months' => 'her %count% ay', + 'every month' => 'aylık', + 'every %count% weeks' => 'her %count% hafta', + 'every week' => 'haftalık', + 'every %count% days' => 'her %count% gün', + 'every day' => 'günlük', + 'last' => 'son', // e.g. 2nd last Friday + 'days' => 'günler', + 'day' => 'gün', + 'weeks' => 'haftalar', + 'week' => 'hafta', + // formats a number with a prefix e.g. every year on the 1st and 200th day + // negative numbers should be handled as in '5th to the last' or 'last' + // + // if has_negatives is true in the params, it is good form to add 'day' after + // each number, as in: 'every month on the 5th day or 2nd to the last day' or + // it may be confusing like 'every month on the 5th or 2nd to the last day' + 'ordinal_number' => function ($str, $params) { + $number = $params['number']; + + $ends = array('th', 'st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th'); + $suffix = ''; + + $isNegative = $number < 0; + + if ($number == -1) { + $abbreviation = 'son'; + } else { + if ($isNegative) { + $number = abs($number); + $suffix = ' sonuna kadar'; + } + + if (($number % 100) >= 11 && ($number % 100) <= 13) { + $abbreviation = $number.'th'; + } else { + $abbreviation = $number.$ends[$number % 10]; + } + } + + if (!empty($params['has_negatives'])) { + $suffix .= ' gün'; + } + + return $abbreviation . $suffix; + }, +); diff --git a/app/log/sql.log b/app/log/sql.log index 45e72f18..cb129c66 100644 --- a/app/log/sql.log +++ b/app/log/sql.log @@ -1,1542 +1,13344 @@ -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select sg.id,sg.groupname,sg.groupcolor,sg.isdefault,COALESCE(count(st.id), 0) AS staffmembers FROM alicehartmann.staffgroups sg LEFT JOIN alicehartmann.staff st ON (st.id_staffgroup = sg.id) WHERE st.isdeleted IS NULL GROUP BY sg.id ORDER BY sg.groupname; -QUERYARRAY: select id,trackername from alicehartmann.timetrackerconfig order by trackername -QUERYARRAY: select ttr.*, st.* ,stg.groupname,COALESCE(st.surname || ' ', '') || COALESCE(st.prename, '') AS staffname,sc.staffstatus from alicehartmann.staff st -LEFT JOIN alicehartmann.staffgroups stg ON st.id_staffgroup = stg.id -left join (select id_staff, case when min(startdate) <= current_date and (max(enddate) is null or max(enddate) >= current_date) then 'current' - when min(startdate) > current_date then 'futur' when max(enddate) < current_date then 'past' else null end as staffstatus,min(startdate)as startdate,max(enddate) as enddate from alicehartmann.staffcontract group by id_staff) sc on (st.id=sc.id_staff) -cross join (select timetrackertype,case when timetrackertype is not null then true else null end as istimetrackerenabled,periodtypes from public.companies where schemata='alicehartmann') ttr -where st.isdeleted is null order by groupname,surname,prename; -QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays, - coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail - FROM alicehartmann.workplans wp - ORDER BY wp.isdefault, wp.workplan; -QUERYARRAY: SELECT id,vacancyname,color - FROM alicehartmann.vacancytypes where isworktime is null or isworktime=false order by vacancyname; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,trackername from alicehartmann.timetrackerconfig order by trackername -QUERYARRAY: select sg.id,sg.groupname,sg.groupcolor,sg.isdefault,COALESCE(count(st.id), 0) AS staffmembers FROM alicehartmann.staffgroups sg LEFT JOIN alicehartmann.staff st ON (st.id_staffgroup = sg.id) WHERE st.isdeleted IS NULL GROUP BY sg.id ORDER BY sg.groupname; -QUERYARRAY: select ttr.*, st.* ,stg.groupname,COALESCE(st.surname || ' ', '') || COALESCE(st.prename, '') AS staffname,sc.staffstatus from alicehartmann.staff st -LEFT JOIN alicehartmann.staffgroups stg ON st.id_staffgroup = stg.id -left join (select id_staff, case when min(startdate) <= current_date and (max(enddate) is null or max(enddate) >= current_date) then 'current' - when min(startdate) > current_date then 'futur' when max(enddate) < current_date then 'past' else null end as staffstatus,min(startdate)as startdate,max(enddate) as enddate from alicehartmann.staffcontract group by id_staff) sc on (st.id=sc.id_staff) -cross join (select timetrackertype,case when timetrackertype is not null then true else null end as istimetrackerenabled,periodtypes from public.companies where schemata='alicehartmann') ttr -where st.isdeleted is null order by groupname,st.staffnumber,surname,prename; -QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays, - coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail - FROM alicehartmann.workplans wp - ORDER BY wp.isdefault, wp.workplan; -QUERYARRAY: SELECT id,vacancyname,color - FROM alicehartmann.vacancytypes where isworktime is null or isworktime=false order by vacancyname; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select sg.id,sg.groupname,sg.groupcolor,sg.isdefault,COALESCE(count(st.id), 0) AS staffmembers FROM alicehartmann.staffgroups sg LEFT JOIN alicehartmann.staff st ON (st.id_staffgroup = sg.id) WHERE st.isdeleted IS NULL GROUP BY sg.id ORDER BY sg.groupname; -QUERYARRAY: select id,trackername from alicehartmann.timetrackerconfig order by trackername -QUERYARRAY: select ttr.*, st.* ,stg.groupname,COALESCE(st.surname || ' ', '') || COALESCE(st.prename, '') AS staffname,sc.staffstatus from alicehartmann.staff st -LEFT JOIN alicehartmann.staffgroups stg ON st.id_staffgroup = stg.id -left join (select id_staff, case when min(startdate) <= current_date and (max(enddate) is null or max(enddate) >= current_date) then 'current' - when min(startdate) > current_date then 'futur' when max(enddate) < current_date then 'past' else null end as staffstatus,min(startdate)as startdate,max(enddate) as enddate from alicehartmann.staffcontract group by id_staff) sc on (st.id=sc.id_staff) -cross join (select timetrackertype,case when timetrackertype is not null then true else null end as istimetrackerenabled,periodtypes from public.companies where schemata='alicehartmann') ttr -where st.isdeleted is null order by groupname,st.staffnumber::INT,surname,prename; -QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays, - coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail - FROM alicehartmann.workplans wp - ORDER BY wp.isdefault, wp.workplan; -QUERYARRAY: SELECT id,vacancyname,color - FROM alicehartmann.vacancytypes where isworktime is null or isworktime=false order by vacancyname; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann'; -QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='alicehartmann'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select terms from public.users where id='e9e6880b-75c7-70b5-ce61-49cf6d62630f'; -QUERYARRAY: SELECT distinct(us.schemaaccess),cp.company, - us.schemaaccess AS schemaname, - cp.datasetname - FROM ( SELECT json_array_elements_text(users.schemaaccess) AS schemaaccess - FROM users WHERE users.isdeleted IS null) us - LEFT JOIN companies cp ON cp.schemata = us.schemaaccess AND cp.isdeleted IS NULL; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select sessiondata from public.sessions where id='f2de1423-f891-08ee-f516-ec4b2ce4c0db' -EXEC: update public.sessions set sessiondata='{"schemata":"kraeltgen"}' where id='f2de1423-f891-08ee-f516-ec4b2ce4c0db' -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,trackername from kraeltgen.timetrackerconfig order by trackername -QUERYARRAY: select sg.id,sg.groupname,sg.groupcolor,sg.isdefault,COALESCE(count(st.id), 0) AS staffmembers FROM kraeltgen.staffgroups sg LEFT JOIN kraeltgen.staff st ON (st.id_staffgroup = sg.id) WHERE st.isdeleted IS NULL GROUP BY sg.id ORDER BY sg.groupname; -QUERYARRAY: select ttr.*, st.* ,stg.groupname,COALESCE(st.surname || ' ', '') || COALESCE(st.prename, '') AS staffname,sc.staffstatus from kraeltgen.staff st -LEFT JOIN kraeltgen.staffgroups stg ON st.id_staffgroup = stg.id -left join (select id_staff, case when min(startdate) <= current_date and (max(enddate) is null or max(enddate) >= current_date) then 'current' - when min(startdate) > current_date then 'futur' when max(enddate) < current_date then 'past' else null end as staffstatus,min(startdate)as startdate,max(enddate) as enddate from alicehartmann.staffcontract group by id_staff) sc on (st.id=sc.id_staff) -cross join (select timetrackertype,case when timetrackertype is not null then true else null end as istimetrackerenabled,periodtypes from public.companies where schemata='kraeltgen') ttr -where st.isdeleted is null order by groupname,st.staffnumber,surname,prename; -QUERYARRAY: SELECT id,vacancyname,color - FROM kraeltgen.vacancytypes where isworktime is null or isworktime=false order by vacancyname; -QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays, - coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail - FROM kraeltgen.workplans wp - ORDER BY wp.isdefault, wp.workplan; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,trackername from kraeltgen.timetrackerconfig order by trackername -QUERYARRAY: select sg.id,sg.groupname,sg.groupcolor,sg.isdefault,COALESCE(count(st.id), 0) AS staffmembers FROM kraeltgen.staffgroups sg LEFT JOIN kraeltgen.staff st ON (st.id_staffgroup = sg.id) WHERE st.isdeleted IS NULL GROUP BY sg.id ORDER BY sg.groupname; -QUERYARRAY: select ttr.*, st.* ,stg.groupname,COALESCE(st.surname || ' ', '') || COALESCE(st.prename, '') AS staffname,sc.staffstatus from kraeltgen.staff st -LEFT JOIN kraeltgen.staffgroups stg ON st.id_staffgroup = stg.id -left join (select id_staff, case when min(startdate) <= current_date and (max(enddate) is null or max(enddate) >= current_date) then 'current' - when min(startdate) > current_date then 'futur' when max(enddate) < current_date then 'past' else null end as staffstatus,min(startdate)as startdate,max(enddate) as enddate from alicehartmann.staffcontract group by id_staff) sc on (st.id=sc.id_staff) -cross join (select timetrackertype,case when timetrackertype is not null then true else null end as istimetrackerenabled,periodtypes from public.companies where schemata='kraeltgen') ttr -where st.isdeleted is null order by groupname,st.staffnumber,surname,prename; -QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays, - coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail - FROM kraeltgen.workplans wp - ORDER BY wp.isdefault, wp.workplan; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select id,trackername from kraeltgen.timetrackerconfig order by trackername -0) AS staffmembers FROM kraeltgen.staffgroups sg LEFT JOIN kraeltgen.staff st ON (st.id_staffgroup = sg.id) WHERE st.isdeleted IS NULL GROUP BY sg.id ORDER BY sg.groupname; -QUERYARRAY: select ttr.*, st.* ,stg.groupname,COALESCE(st.surname || ' ', '') || COALESCE(st.prename, '') AS staffname,sc.staffstatus from kraeltgen.staff st -LEFT JOIN kraeltgen.staffgroups stg ON st.id_staffgroup = stg.id -left join (select id_staff, case when min(startdate) <= current_date and (max(enddate) is null or max(enddate) >= current_date) then 'current' - when min(startdate) > current_date then 'futur' when max(enddate) < current_date then 'past' else null end as staffstatus,min(startdate)as startdate,max(enddate) as enddate from kraeltgen.staffcontract group by id_staff) sc on (st.id=sc.id_staff) -cross join (select timetrackertype,case when timetrackertype is not null then true else null end as istimetrackerenabled,periodtypes from public.companies where schemata='kraeltgen') ttr -where st.isdeleted is null order by groupname,st.staffnumber,surname,prename; -QUERYARRAY: SELECT id,vacancyname,color - FROM kraeltgen.vacancytypes where isworktime is null or isworktime=false order by vacancyname; -QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays, - coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail - FROM kraeltgen.workplans wp - ORDER BY wp.isdefault, wp.workplan; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select * from kraeltgen.staff where id='f18a67e3-1b2f-dbed-85e9-1b35912f943e' and isdeleted is null; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT st.prename, st.surname, coalesce(st.surname || ' ','') || coalesce(st.prename,'') as name, - to_char(srp.contracthours, 'HH24:MI'::text) AS contracthours, - to_char(srp.workhours, 'HH24:MI'::text) AS workhours, - --to_char(srp.vacancyhours, 'HH24:MI'::text) AS vacancyhours, - to_char(srp.vacancyill, 'HH24:MI'::text) AS vacancyill, - to_char(srp.vacancynormal, 'HH24:MI'::text) AS vacancynormal, - to_char(srp.vacancyextra, 'HH24:MI'::text) AS vacancyextra, - to_char(srp.otherpaidhours, 'HH24:MI'::text) AS otherpaidhours, - to_char(srp.partunemplhours, 'HH24:MI'::text) AS partunemplhours, - to_char(srp.recuperationhours, 'HH24:MI'::text) AS recuperationhours, - case when position('-' in to_char(srp.hoursdiff, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.hoursdiff, 'HH24:MI'),'-','') else to_char(srp.hoursdiff, 'HH24:MI') end as hoursdiff, - to_char(srp.totalhours, 'HH24:MI'::text) AS totalhours, - srp.id as id_staffreportperiod,srp.id_reportperiod, srp.id_staff, srp.id, rp.startdate, rp.enddate, - COALESCE(st.surname || ' '::text, ''::text) || COALESCE(st.prename, ''::text) AS staffname, - st.id_staffgroup, sgr.groupname, - case when position('-' in to_char(srp.transferedhours, 'HH24:MI')) > 0 then '-' || replace(to_char(srp.transferedhours, 'HH24:MI'),'-','') else to_char(srp.transferedhours, 'HH24:MI') end as transferedhours, - case when suppvacancysunwork is not null and suppvacancysunwork > 0 then '+' || suppvacancysunwork else null end as suppvacancysunwork, - case when suppvacancy44hours is not null and suppvacancy44hours > 0 then '+' || suppvacancy44hours else null end as suppvacancy44hours - ,itmcontracthours,maxdays,srp.isvalidated, - to_char(srp.payedhours40calc,'HH24:MI'::text) AS payedhours, - to_char(payedhours0, 'HH24:MI'::text) as payedhours0, - to_char(payedhours40, 'HH24:MI'::text) as payedhours40, - to_char(payedhours40calc, 'HH24:MI'::text) as payedhours40calc, - to_char(hourstotransfer, 'HH24:MI'::text) as hourstotransfer, - to_char(hourstotransfercalc, 'HH24:MI'::text) as hourstotransfercalc, - to_char(srp.avgtotalweekhours, 'HH24:MI'::text) AS avgtotalweekhours - FROM kraeltgen.staffreportperiod srp - LEFT JOIN kraeltgen.staff st ON srp.id_staff = st.id - LEFT JOIN kraeltgen.reportperiod rp ON srp.id_reportperiod = rp.id - LEFT JOIN kraeltgen.staffgroups sgr ON st.id_staffgroup = sgr.id - WHERE st.isdeleted IS NULL AND srp.id_staff = 'f18a67e3-1b2f-dbed-85e9-1b35912f943e' - ORDER BY st.surname, st.prename, srp.id_staff, rp.startdate, rp.enddate; -QUERYARRAY: select id,id_staff,vacyear,to_char(vachours,'HH24:MI') as vachours from kraeltgen.staffvacancyyear where id_staff='f18a67e3-1b2f-dbed-85e9-1b35912f943e' order by vacyear; -QUERYARRAY: SELECT id,id as id_staffcontract,id_staff,startdate,enddate,weekdays,to_char(weekhours, 'HH24:MI'::text) AS weekhours,defaultfreedays from kraeltgen.staffcontract where id_staff='f18a67e3-1b2f-dbed-85e9-1b35912f943e' order by startdate,enddate; -QUERYARRAY: select to_char(daydate,'YYYY') as vacyear,daydate, - to_char(vacancyhours::interval,'HH24:MI') as vacancyhours, - to_char(vacillhours::interval,'HH24:MI') as vacillhours, - to_char(vacextrahours::interval,'HH24:MI') as vacextrahours, - coalesce ('
' || vacancycomment || '
','') || coalesce('
' || vacillcomment|| '
','') || coalesce('
' || vacextracomment|| '
','') as description - from kraeltgen.staffreportperioddays where (vacancyhours is not null or vacillhours is not null or vacextrahours is not null) and id_staff='f18a67e3-1b2f-dbed-85e9-1b35912f943e' order by daydate; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select terms from public.users where id='e9e6880b-75c7-70b5-ce61-49cf6d62630f'; -QUERYARRAY: SELECT distinct(us.schemaaccess),cp.company, - us.schemaaccess AS schemaname, - cp.datasetname - FROM ( SELECT json_array_elements_text(users.schemaaccess) AS schemaaccess - FROM users WHERE users.isdeleted IS null) us - LEFT JOIN companies cp ON cp.schemata = us.schemaaccess AND cp.isdeleted IS NULL; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays, - coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail - FROM kraeltgen.workplans wp - ORDER BY wp.isdefault, wp.workplan; -QUERYARRAY: SELECT id,startdate,enddate,id_parentreportperiod,periodtype,subinterval,viewpartunempl,to_char(startdate,'MM/YY') || ' - ' || to_char(enddate,'MM/YY') as dspperiod FROM kraeltgen.reportperiod rp ORDER BY startdate, enddate; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='kraeltgen'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT distinct(us.schemaaccess),cp.company, - us.schemaaccess AS schemaname, - cp.datasetname - FROM ( SELECT json_array_elements_text(users.schemaaccess) AS schemaaccess - FROM users WHERE users.isdeleted IS null) us - LEFT JOIN companies cp ON cp.schemata = us.schemaaccess AND cp.isdeleted IS NULL; -QUERY: select terms from public.users where id='e9e6880b-75c7-70b5-ce61-49cf6d62630f'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select sessiondata from public.sessions where id='f2de1423-f891-08ee-f516-ec4b2ce4c0db' -EXEC: update public.sessions set sessiondata='{"schemata":"davincenzo"}' where id='f2de1423-f891-08ee-f516-ec4b2ce4c0db' -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT distinct(us.schemaaccess),cp.company, - us.schemaaccess AS schemaname, - cp.datasetname - FROM ( SELECT json_array_elements_text(users.schemaaccess) AS schemaaccess - FROM users WHERE users.isdeleted IS null) us - LEFT JOIN companies cp ON cp.schemata = us.schemaaccess AND cp.isdeleted IS NULL; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT id,startdate,enddate,id_parentreportperiod,periodtype,subinterval,viewpartunempl,to_char(startdate,'MM/YY') || ' - ' || to_char(enddate,'MM/YY') as dspperiod FROM davincenzo.reportperiod rp ORDER BY startdate, enddate; -QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays, - coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail - FROM davincenzo.workplans wp - ORDER BY wp.isdefault, wp.workplan; -QUERYARRAY: SELECT id,vacancyname,color - FROM davincenzo.vacancytypes where isworktime is null or isworktime=false order by vacancyname; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select terms from public.users where id='e9e6880b-75c7-70b5-ce61-49cf6d62630f'; -QUERYARRAY: SELECT distinct(us.schemaaccess),cp.company, - us.schemaaccess AS schemaname, - cp.datasetname - FROM ( SELECT json_array_elements_text(users.schemaaccess) AS schemaaccess - FROM users WHERE users.isdeleted IS null) us - LEFT JOIN companies cp ON cp.schemata = us.schemaaccess AND cp.isdeleted IS NULL; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select sg.id,sg.groupname,sg.groupcolor,sg.isdefault,COALESCE(count(st.id), 0) AS staffmembers FROM davincenzo.staffgroups sg LEFT JOIN davincenzo.staff st ON (st.id_staffgroup = sg.id) WHERE st.isdeleted IS NULL GROUP BY sg.id ORDER BY sg.groupname; -QUERYARRAY: select id,trackername from davincenzo.timetrackerconfig order by trackername -QUERYARRAY: select ttr.*, st.* ,stg.groupname,COALESCE(st.surname || ' ', '') || COALESCE(st.prename, '') AS staffname,sc.staffstatus from davincenzo.staff st -LEFT JOIN davincenzo.staffgroups stg ON st.id_staffgroup = stg.id -left join (select id_staff, case when min(startdate) <= current_date and (max(enddate) is null or max(enddate) >= current_date) then 'current' - when min(startdate) > current_date then 'futur' when max(enddate) < current_date then 'past' else null end as staffstatus,min(startdate)as startdate,max(enddate) as enddate from davincenzo.staffcontract group by id_staff) sc on (st.id=sc.id_staff) -cross join (select timetrackertype,case when timetrackertype is not null then true else null end as istimetrackerenabled,periodtypes from public.companies where schemata='davincenzo') ttr -where st.isdeleted is null order by groupname,st.staffnumber,surname,prename; -QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays, - coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail - FROM davincenzo.workplans wp - ORDER BY wp.isdefault, wp.workplan; -QUERYARRAY: SELECT id,vacancyname,color - FROM davincenzo.vacancytypes where isworktime is null or isworktime=false order by vacancyname; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select terms from public.users where id='e9e6880b-75c7-70b5-ce61-49cf6d62630f'; -QUERYARRAY: SELECT distinct(us.schemaaccess),cp.company, - us.schemaaccess AS schemaname, - cp.datasetname - FROM ( SELECT json_array_elements_text(users.schemaaccess) AS schemaaccess - FROM users WHERE users.isdeleted IS null) us - LEFT JOIN companies cp ON cp.schemata = us.schemaaccess AND cp.isdeleted IS NULL; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select sg.id,sg.groupname,sg.groupcolor,sg.isdefault,COALESCE(count(st.id), 0) AS staffmembers FROM davincenzo.staffgroups sg LEFT JOIN davincenzo.staff st ON (st.id_staffgroup = sg.id) WHERE st.isdeleted IS NULL GROUP BY sg.id ORDER BY sg.groupname; -QUERYARRAY: select id,trackername from davincenzo.timetrackerconfig order by trackername -QUERYARRAY: select ttr.*, st.* ,stg.groupname,COALESCE(st.surname || ' ', '') || COALESCE(st.prename, '') AS staffname,sc.staffstatus from davincenzo.staff st -LEFT JOIN davincenzo.staffgroups stg ON st.id_staffgroup = stg.id -left join (select id_staff, case when min(startdate) <= current_date and (max(enddate) is null or max(enddate) >= current_date) then 'current' - when min(startdate) > current_date then 'futur' when max(enddate) < current_date then 'past' else null end as staffstatus,min(startdate)as startdate,max(enddate) as enddate from davincenzo.staffcontract group by id_staff) sc on (st.id=sc.id_staff) -cross join (select timetrackertype,case when timetrackertype is not null then true else null end as istimetrackerenabled,periodtypes from public.companies where schemata='davincenzo') ttr -where st.isdeleted is null order by groupname,st.staffnumber,surname,prename; -QUERYARRAY: SELECT id,vacancyname,color - FROM davincenzo.vacancytypes where isworktime is null or isworktime=false order by vacancyname; -QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays, - coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail - FROM davincenzo.workplans wp - ORDER BY wp.isdefault, wp.workplan; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT distinct(us.schemaaccess),cp.company, - us.schemaaccess AS schemaname, - cp.datasetname - FROM ( SELECT json_array_elements_text(users.schemaaccess) AS schemaaccess - FROM users WHERE users.isdeleted IS null) us - LEFT JOIN companies cp ON cp.schemata = us.schemaaccess AND cp.isdeleted IS NULL; -QUERY: select terms from public.users where id='e9e6880b-75c7-70b5-ce61-49cf6d62630f'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: SELECT * FROM public.companies WHERE schemata='davincenzo' and isdeleted IS NULL; -QUERYARRAY: SELECT wp.id,wp.workplan,wp.isdefault,wp.weekhours,wp.weekdays, - coalesce((((((wp.workplan || ' / ') ||substr(wp.weekhours::text, 1, 5)) || 'h / ') || wp.weekdays) || 'j / libre: ') || (( SELECT string_agg(ww.wday, ',') AS string_agg FROM ( SELECT public.day_name(json_array_elements_text(wp.freeweekdayslist)) AS wday) ww)),wp.workplan ) AS dspworkplandetail - FROM davincenzo.workplans wp - ORDER BY wp.isdefault, wp.workplan; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: SELECT distinct(us.schemaaccess),cp.company, - us.schemaaccess AS schemaname, - cp.datasetname - FROM ( SELECT json_array_elements_text(users.schemaaccess) AS schemaaccess - FROM users WHERE users.isdeleted IS null) us - LEFT JOIN companies cp ON cp.schemata = us.schemaaccess AND cp.isdeleted IS NULL; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select timetrackertype,sector from public.companies where schemata='davincenzo'; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: SELECT * FROM public.companies WHERE schemata='davincenzo' and isdeleted IS NULL; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERY: select se.id as idsession,us.lang,us.id,us.username,ugrp.id as usergroup,us.id_staffgroups as staffgroups,se.sessiondata from sessions se - join users us on (us.id=se.id_user) - left join usergroups ugrp on (ugrp.id=us.id_usergroup) - where se.id= 'f2de1423-f891-08ee-f516-ec4b2ce4c0db' and se.remote_addr= '::1' and se.user_agent ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36' and - us.isblocked is null group by se.id,us.id,ugrp.id; -QUERYARRAY: select * from ( -SELECT us.username,us.isblocked,us.surname,us.prename,us.id_company,us.id_usergroup,us.id,cp.company,cp.datasetname,grp.groupname,us.lang, -case when us.id_usergroup = 'teamleader' then string_agg(stgrp.groupname,',') else null end as staffgroups, - json_array_elements_text(us.schemaaccess) AS xschema - FROM public.users us join public.companies cp on (us.id_company=cp.id) - left join public.usergroups grp on (us.id_usergroup=grp.id) - left join (select stu.id as id_user,stu.id_staffgroup,stg.groupname from davincenzo.staffgroups stg -join (select id,json_array_elements_text(id_staffgroups) as id_staffgroup from public.users) stu on (stu.id_staffgroup=stg.id)) stgrp on (us.id=stgrp.id_user) - WHERE us.isdeleted IS null and id_usergroup in ('teamleader','manager') group by us.id,cp.id,grp.id - ) xus where xschema='davincenzo' group by xus.id,xus.username,xus.groupname,xus.isblocked,xus.surname,xus.prename,xus.id_company,xus.id_usergroup,xus.company,xus.datasetname,xus.xschema,xus.staffgroups,xus.lang; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'083eb8a2-1bb3-abca-25fb-ce5939d99398' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' group by rp.id); +EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff) + VALUES ('a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4','083eb8a2-1bb3-abca-25fb-ce5939d99398') on conflict on constraint uniq_staffreportperiod_cal do nothing; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'083eb8a2-1bb3-abca-25fb-ce5939d99398' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' group by rp.id); +EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff) + VALUES ('21fd24f3-d9c0-fbae-a078-ec3fabcc2b64','083eb8a2-1bb3-abca-25fb-ce5939d99398') on conflict on constraint uniq_staffreportperiod_cal do nothing; +EXEC: update hotelplacedarme.staffreportperiod set maxdays=null,contracthours=null where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and id_reportperiod='a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4'; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperiod set maxdays=null,contracthours=null where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and id_reportperiod='21fd24f3-d9c0-fbae-a078-ec3fabcc2b64'; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-02-01') and date('2022-02-28') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffvacancyyear (id_staff,vacyear) + select id_staff,to_char(daydate,'YYYY')::int4 as vyear from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' group by id_staff,vyear order by id_staff,vyear + on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'083eb8a2-1bb3-abca-25fb-ce5939d99398' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' group by rp.id); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'083eb8a2-1bb3-abca-25fb-ce5939d99398' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' group by rp.id); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-02-01') and date('2022-02-28') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'b0dba065-1542-4579-18c7-d821a1da7a4b' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' group by rp.id); +EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff) + VALUES ('a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4','b0dba065-1542-4579-18c7-d821a1da7a4b') on conflict on constraint uniq_staffreportperiod_cal do nothing; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'b0dba065-1542-4579-18c7-d821a1da7a4b' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' group by rp.id); +EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff) + VALUES ('21fd24f3-d9c0-fbae-a078-ec3fabcc2b64','b0dba065-1542-4579-18c7-d821a1da7a4b') on conflict on constraint uniq_staffreportperiod_cal do nothing; +EXEC: update hotelplacedarme.staffreportperiod set maxdays=null,contracthours=null where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and id_reportperiod='a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4'; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperiod set maxdays=null,contracthours=null where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and id_reportperiod='21fd24f3-d9c0-fbae-a078-ec3fabcc2b64'; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-02-01') and date('2022-02-28') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffvacancyyear (id_staff,vacyear) + select id_staff,to_char(daydate,'YYYY')::int4 as vyear from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' group by id_staff,vyear order by id_staff,vyear + on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'b0dba065-1542-4579-18c7-d821a1da7a4b' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' group by rp.id); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'b0dba065-1542-4579-18c7-d821a1da7a4b' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' group by rp.id); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-02-01') and date('2022-02-28') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'57a7e41e-2836-64b4-634a-14d90466b457' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='57a7e41e-2836-64b4-634a-14d90466b457' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' group by rp.id); +EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff) + VALUES ('a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4','57a7e41e-2836-64b4-634a-14d90466b457') on conflict on constraint uniq_staffreportperiod_cal do nothing; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'57a7e41e-2836-64b4-634a-14d90466b457' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='57a7e41e-2836-64b4-634a-14d90466b457' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' group by rp.id); +EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff) + VALUES ('21fd24f3-d9c0-fbae-a078-ec3fabcc2b64','57a7e41e-2836-64b4-634a-14d90466b457') on conflict on constraint uniq_staffreportperiod_cal do nothing; +EXEC: update hotelplacedarme.staffreportperiod set maxdays=null,contracthours=null where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and id_reportperiod='a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4'; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperiod set maxdays=null,contracthours=null where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and id_reportperiod='21fd24f3-d9c0-fbae-a078-ec3fabcc2b64'; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64') + where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-02-01') and date('2022-02-28') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffvacancyyear (id_staff,vacyear) + select id_staff,to_char(daydate,'YYYY')::int4 as vyear from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' group by id_staff,vyear order by id_staff,vyear + on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'57a7e41e-2836-64b4-634a-14d90466b457' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='57a7e41e-2836-64b4-634a-14d90466b457' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' group by rp.id); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'57a7e41e-2836-64b4-634a-14d90466b457' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='57a7e41e-2836-64b4-634a-14d90466b457' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' group by rp.id); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64') + where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-02-01') and date('2022-02-28') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'79a916f1-ad2c-1189-838d-b150e07fbdb8' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' group by rp.id); +EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff) + VALUES ('a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4','79a916f1-ad2c-1189-838d-b150e07fbdb8') on conflict on constraint uniq_staffreportperiod_cal do nothing; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'79a916f1-ad2c-1189-838d-b150e07fbdb8' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' group by rp.id); +EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff) + VALUES ('21fd24f3-d9c0-fbae-a078-ec3fabcc2b64','79a916f1-ad2c-1189-838d-b150e07fbdb8') on conflict on constraint uniq_staffreportperiod_cal do nothing; +EXEC: update hotelplacedarme.staffreportperiod set maxdays=null,contracthours=null where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and id_reportperiod='a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4'; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperiod set maxdays=null,contracthours=null where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and id_reportperiod='21fd24f3-d9c0-fbae-a078-ec3fabcc2b64'; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-02-01') and date('2022-02-28') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffvacancyyear (id_staff,vacyear) + select id_staff,to_char(daydate,'YYYY')::int4 as vyear from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' group by id_staff,vyear order by id_staff,vyear + on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'79a916f1-ad2c-1189-838d-b150e07fbdb8' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' group by rp.id); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'79a916f1-ad2c-1189-838d-b150e07fbdb8' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' group by rp.id); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-02-01') and date('2022-02-28') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'14b54eaf-e63a-7b72-9a82-f11bb533f5e2' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' group by rp.id); +EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff) + VALUES ('a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4','14b54eaf-e63a-7b72-9a82-f11bb533f5e2') on conflict on constraint uniq_staffreportperiod_cal do nothing; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'14b54eaf-e63a-7b72-9a82-f11bb533f5e2' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' group by rp.id); +EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff) + VALUES ('21fd24f3-d9c0-fbae-a078-ec3fabcc2b64','14b54eaf-e63a-7b72-9a82-f11bb533f5e2') on conflict on constraint uniq_staffreportperiod_cal do nothing; +EXEC: update hotelplacedarme.staffreportperiod set maxdays=null,contracthours=null where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and id_reportperiod='a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4'; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperiod set maxdays=null,contracthours=null where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and id_reportperiod='21fd24f3-d9c0-fbae-a078-ec3fabcc2b64'; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64') + where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and pd.daydate between date('2022-02-01') and date('2022-02-28') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffvacancyyear (id_staff,vacyear) + select id_staff,to_char(daydate,'YYYY')::int4 as vyear from hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' group by id_staff,vyear order by id_staff,vyear + on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'14b54eaf-e63a-7b72-9a82-f11bb533f5e2' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' group by rp.id); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'14b54eaf-e63a-7b72-9a82-f11bb533f5e2' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' group by rp.id); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64') + where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and pd.daydate between date('2022-02-01') and date('2022-02-28') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'4067ca66-58fe-01ca-1cbb-78e321010c20' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' group by rp.id); +EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff) + VALUES ('a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4','4067ca66-58fe-01ca-1cbb-78e321010c20') on conflict on constraint uniq_staffreportperiod_cal do nothing; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'4067ca66-58fe-01ca-1cbb-78e321010c20' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' group by rp.id); +EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff) + VALUES ('21fd24f3-d9c0-fbae-a078-ec3fabcc2b64','4067ca66-58fe-01ca-1cbb-78e321010c20') on conflict on constraint uniq_staffreportperiod_cal do nothing; +EXEC: update hotelplacedarme.staffreportperiod set maxdays=null,contracthours=null where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and id_reportperiod='a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4'; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperiod set maxdays=null,contracthours=null where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and id_reportperiod='21fd24f3-d9c0-fbae-a078-ec3fabcc2b64'; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64') + where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and pd.daydate between date('2022-02-01') and date('2022-02-28') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffvacancyyear (id_staff,vacyear) + select id_staff,to_char(daydate,'YYYY')::int4 as vyear from hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' group by id_staff,vyear order by id_staff,vyear + on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'4067ca66-58fe-01ca-1cbb-78e321010c20' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' group by rp.id); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'4067ca66-58fe-01ca-1cbb-78e321010c20' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' group by rp.id); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64') + where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and pd.daydate between date('2022-02-01') and date('2022-02-28') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'083eb8a2-1bb3-abca-25fb-ce5939d99398' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' group by rp.id); +EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff) + VALUES ('a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4','083eb8a2-1bb3-abca-25fb-ce5939d99398') on conflict on constraint uniq_staffreportperiod_cal do nothing; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'083eb8a2-1bb3-abca-25fb-ce5939d99398' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' group by rp.id); +EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff) + VALUES ('21fd24f3-d9c0-fbae-a078-ec3fabcc2b64','083eb8a2-1bb3-abca-25fb-ce5939d99398') on conflict on constraint uniq_staffreportperiod_cal do nothing; +EXEC: update hotelplacedarme.staffreportperiod set maxdays=21,contracthours='168:00:00' where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and id_reportperiod='a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4'; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperiod set maxdays=20,contracthours='160:00:00' where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and id_reportperiod='21fd24f3-d9c0-fbae-a078-ec3fabcc2b64'; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-02-01') and date('2022-02-28') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffvacancyyear (id_staff,vacyear) + select id_staff,to_char(daydate,'YYYY')::int4 as vyear from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' group by id_staff,vyear order by id_staff,vyear + on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'083eb8a2-1bb3-abca-25fb-ce5939d99398' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' group by rp.id); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'083eb8a2-1bb3-abca-25fb-ce5939d99398' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' group by rp.id); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-02-01') and date('2022-02-28') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'b0dba065-1542-4579-18c7-d821a1da7a4b' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' group by rp.id); +EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff) + VALUES ('a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4','b0dba065-1542-4579-18c7-d821a1da7a4b') on conflict on constraint uniq_staffreportperiod_cal do nothing; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'b0dba065-1542-4579-18c7-d821a1da7a4b' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' group by rp.id); +EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff) + VALUES ('21fd24f3-d9c0-fbae-a078-ec3fabcc2b64','b0dba065-1542-4579-18c7-d821a1da7a4b') on conflict on constraint uniq_staffreportperiod_cal do nothing; +EXEC: update hotelplacedarme.staffreportperiod set maxdays=23,contracthours='184:00:00' where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and id_reportperiod='a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4'; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperiod set maxdays=20,contracthours='160:00:00' where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and id_reportperiod='21fd24f3-d9c0-fbae-a078-ec3fabcc2b64'; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-02-01') and date('2022-02-28') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffvacancyyear (id_staff,vacyear) + select id_staff,to_char(daydate,'YYYY')::int4 as vyear from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' group by id_staff,vyear order by id_staff,vyear + on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'b0dba065-1542-4579-18c7-d821a1da7a4b' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' group by rp.id); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'b0dba065-1542-4579-18c7-d821a1da7a4b' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' group by rp.id); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-02-01') and date('2022-02-28') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'57a7e41e-2836-64b4-634a-14d90466b457' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='57a7e41e-2836-64b4-634a-14d90466b457' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' group by rp.id); +EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff) + VALUES ('a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4','57a7e41e-2836-64b4-634a-14d90466b457') on conflict on constraint uniq_staffreportperiod_cal do nothing; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'57a7e41e-2836-64b4-634a-14d90466b457' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='57a7e41e-2836-64b4-634a-14d90466b457' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' group by rp.id); +EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff) + VALUES ('21fd24f3-d9c0-fbae-a078-ec3fabcc2b64','57a7e41e-2836-64b4-634a-14d90466b457') on conflict on constraint uniq_staffreportperiod_cal do nothing; +EXEC: update hotelplacedarme.staffreportperiod set maxdays=21,contracthours='168:00:00' where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and id_reportperiod='a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4'; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperiod set maxdays=20,contracthours='160:00:00' where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and id_reportperiod='21fd24f3-d9c0-fbae-a078-ec3fabcc2b64'; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64') + where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-02-01') and date('2022-02-28') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffvacancyyear (id_staff,vacyear) + select id_staff,to_char(daydate,'YYYY')::int4 as vyear from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' group by id_staff,vyear order by id_staff,vyear + on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'57a7e41e-2836-64b4-634a-14d90466b457' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='57a7e41e-2836-64b4-634a-14d90466b457' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' group by rp.id); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'57a7e41e-2836-64b4-634a-14d90466b457' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='57a7e41e-2836-64b4-634a-14d90466b457' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' group by rp.id); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64') + where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-02-01') and date('2022-02-28') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'79a916f1-ad2c-1189-838d-b150e07fbdb8' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' group by rp.id); +EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff) + VALUES ('a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4','79a916f1-ad2c-1189-838d-b150e07fbdb8') on conflict on constraint uniq_staffreportperiod_cal do nothing; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'79a916f1-ad2c-1189-838d-b150e07fbdb8' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' group by rp.id); +EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff) + VALUES ('21fd24f3-d9c0-fbae-a078-ec3fabcc2b64','79a916f1-ad2c-1189-838d-b150e07fbdb8') on conflict on constraint uniq_staffreportperiod_cal do nothing; +EXEC: update hotelplacedarme.staffreportperiod set maxdays=23,contracthours='184:00:00' where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and id_reportperiod='a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4'; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperiod set maxdays=20,contracthours='160:00:00' where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and id_reportperiod='21fd24f3-d9c0-fbae-a078-ec3fabcc2b64'; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-02-01') and date('2022-02-28') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffvacancyyear (id_staff,vacyear) + select id_staff,to_char(daydate,'YYYY')::int4 as vyear from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' group by id_staff,vyear order by id_staff,vyear + on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'79a916f1-ad2c-1189-838d-b150e07fbdb8' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' group by rp.id); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'79a916f1-ad2c-1189-838d-b150e07fbdb8' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' group by rp.id); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-02-01') and date('2022-02-28') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'14b54eaf-e63a-7b72-9a82-f11bb533f5e2' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' group by rp.id); +EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff) + VALUES ('a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4','14b54eaf-e63a-7b72-9a82-f11bb533f5e2') on conflict on constraint uniq_staffreportperiod_cal do nothing; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'14b54eaf-e63a-7b72-9a82-f11bb533f5e2' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' group by rp.id); +EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff) + VALUES ('21fd24f3-d9c0-fbae-a078-ec3fabcc2b64','14b54eaf-e63a-7b72-9a82-f11bb533f5e2') on conflict on constraint uniq_staffreportperiod_cal do nothing; +EXEC: update hotelplacedarme.staffreportperiod set maxdays=23,contracthours='184:00:00' where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and id_reportperiod='a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4'; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperiod set maxdays=20,contracthours='160:00:00' where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and id_reportperiod='21fd24f3-d9c0-fbae-a078-ec3fabcc2b64'; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64') + where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and pd.daydate between date('2022-02-01') and date('2022-02-28') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffvacancyyear (id_staff,vacyear) + select id_staff,to_char(daydate,'YYYY')::int4 as vyear from hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' group by id_staff,vyear order by id_staff,vyear + on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'14b54eaf-e63a-7b72-9a82-f11bb533f5e2' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' group by rp.id); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'14b54eaf-e63a-7b72-9a82-f11bb533f5e2' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' group by rp.id); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64') + where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and pd.daydate between date('2022-02-01') and date('2022-02-28') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'4067ca66-58fe-01ca-1cbb-78e321010c20' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' group by rp.id); +EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff) + VALUES ('a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4','4067ca66-58fe-01ca-1cbb-78e321010c20') on conflict on constraint uniq_staffreportperiod_cal do nothing; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'4067ca66-58fe-01ca-1cbb-78e321010c20' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' group by rp.id); +EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff) + VALUES ('21fd24f3-d9c0-fbae-a078-ec3fabcc2b64','4067ca66-58fe-01ca-1cbb-78e321010c20') on conflict on constraint uniq_staffreportperiod_cal do nothing; +EXEC: update hotelplacedarme.staffreportperiod set maxdays=21,contracthours='168:00:00' where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and id_reportperiod='a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4'; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperiod set maxdays=20,contracthours='160:00:00' where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and id_reportperiod='21fd24f3-d9c0-fbae-a078-ec3fabcc2b64'; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64') + where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and pd.daydate between date('2022-02-01') and date('2022-02-28') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffvacancyyear (id_staff,vacyear) + select id_staff,to_char(daydate,'YYYY')::int4 as vyear from hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' group by id_staff,vyear order by id_staff,vyear + on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'4067ca66-58fe-01ca-1cbb-78e321010c20' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' group by rp.id); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'4067ca66-58fe-01ca-1cbb-78e321010c20' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' group by rp.id); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64') + where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and pd.daydate between date('2022-02-01') and date('2022-02-28') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'083eb8a2-1bb3-abca-25fb-ce5939d99398' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' group by rp.id); +EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff) + VALUES ('a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4','083eb8a2-1bb3-abca-25fb-ce5939d99398') on conflict on constraint uniq_staffreportperiod_cal do nothing; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'083eb8a2-1bb3-abca-25fb-ce5939d99398' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' group by rp.id); +EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff) + VALUES ('21fd24f3-d9c0-fbae-a078-ec3fabcc2b64','083eb8a2-1bb3-abca-25fb-ce5939d99398') on conflict on constraint uniq_staffreportperiod_cal do nothing; +EXEC: update hotelplacedarme.staffreportperiod set maxdays=21,contracthours='168:00:00' where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and id_reportperiod='a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4'; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperiod set maxdays=20,contracthours='160:00:00' where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and id_reportperiod='21fd24f3-d9c0-fbae-a078-ec3fabcc2b64'; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-02-01') and date('2022-02-28') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffvacancyyear (id_staff,vacyear) + select id_staff,to_char(daydate,'YYYY')::int4 as vyear from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' group by id_staff,vyear order by id_staff,vyear + on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'083eb8a2-1bb3-abca-25fb-ce5939d99398' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' group by rp.id); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'083eb8a2-1bb3-abca-25fb-ce5939d99398' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' group by rp.id); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-02-01') and date('2022-02-28') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'b0dba065-1542-4579-18c7-d821a1da7a4b' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' group by rp.id); +EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff) + VALUES ('a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4','b0dba065-1542-4579-18c7-d821a1da7a4b') on conflict on constraint uniq_staffreportperiod_cal do nothing; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'b0dba065-1542-4579-18c7-d821a1da7a4b' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' group by rp.id); +EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff) + VALUES ('21fd24f3-d9c0-fbae-a078-ec3fabcc2b64','b0dba065-1542-4579-18c7-d821a1da7a4b') on conflict on constraint uniq_staffreportperiod_cal do nothing; +EXEC: update hotelplacedarme.staffreportperiod set maxdays=23,contracthours='184:00:00' where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and id_reportperiod='a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4'; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperiod set maxdays=20,contracthours='160:00:00' where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and id_reportperiod='21fd24f3-d9c0-fbae-a078-ec3fabcc2b64'; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-02-01') and date('2022-02-28') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffvacancyyear (id_staff,vacyear) + select id_staff,to_char(daydate,'YYYY')::int4 as vyear from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' group by id_staff,vyear order by id_staff,vyear + on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'b0dba065-1542-4579-18c7-d821a1da7a4b' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' group by rp.id); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'b0dba065-1542-4579-18c7-d821a1da7a4b' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' group by rp.id); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-02-01') and date('2022-02-28') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'57a7e41e-2836-64b4-634a-14d90466b457' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='57a7e41e-2836-64b4-634a-14d90466b457' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' group by rp.id); +EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff) + VALUES ('a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4','57a7e41e-2836-64b4-634a-14d90466b457') on conflict on constraint uniq_staffreportperiod_cal do nothing; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'57a7e41e-2836-64b4-634a-14d90466b457' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='57a7e41e-2836-64b4-634a-14d90466b457' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' group by rp.id); +EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff) + VALUES ('21fd24f3-d9c0-fbae-a078-ec3fabcc2b64','57a7e41e-2836-64b4-634a-14d90466b457') on conflict on constraint uniq_staffreportperiod_cal do nothing; +EXEC: update hotelplacedarme.staffreportperiod set maxdays=21,contracthours='168:00:00' where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and id_reportperiod='a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4'; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperiod set maxdays=20,contracthours='160:00:00' where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and id_reportperiod='21fd24f3-d9c0-fbae-a078-ec3fabcc2b64'; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64') + where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-02-01') and date('2022-02-28') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffvacancyyear (id_staff,vacyear) + select id_staff,to_char(daydate,'YYYY')::int4 as vyear from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' group by id_staff,vyear order by id_staff,vyear + on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'57a7e41e-2836-64b4-634a-14d90466b457' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='57a7e41e-2836-64b4-634a-14d90466b457' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' group by rp.id); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'57a7e41e-2836-64b4-634a-14d90466b457' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='57a7e41e-2836-64b4-634a-14d90466b457' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' group by rp.id); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64') + where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-02-01') and date('2022-02-28') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'79a916f1-ad2c-1189-838d-b150e07fbdb8' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' group by rp.id); +EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff) + VALUES ('a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4','79a916f1-ad2c-1189-838d-b150e07fbdb8') on conflict on constraint uniq_staffreportperiod_cal do nothing; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'79a916f1-ad2c-1189-838d-b150e07fbdb8' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' group by rp.id); +EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff) + VALUES ('21fd24f3-d9c0-fbae-a078-ec3fabcc2b64','79a916f1-ad2c-1189-838d-b150e07fbdb8') on conflict on constraint uniq_staffreportperiod_cal do nothing; +EXEC: update hotelplacedarme.staffreportperiod set maxdays=23,contracthours='184:00:00' where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and id_reportperiod='a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4'; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperiod set maxdays=20,contracthours='160:00:00' where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and id_reportperiod='21fd24f3-d9c0-fbae-a078-ec3fabcc2b64'; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-02-01') and date('2022-02-28') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffvacancyyear (id_staff,vacyear) + select id_staff,to_char(daydate,'YYYY')::int4 as vyear from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' group by id_staff,vyear order by id_staff,vyear + on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'79a916f1-ad2c-1189-838d-b150e07fbdb8' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' group by rp.id); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'79a916f1-ad2c-1189-838d-b150e07fbdb8' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' group by rp.id); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-02-01') and date('2022-02-28') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'14b54eaf-e63a-7b72-9a82-f11bb533f5e2' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' group by rp.id); +EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff) + VALUES ('a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4','14b54eaf-e63a-7b72-9a82-f11bb533f5e2') on conflict on constraint uniq_staffreportperiod_cal do nothing; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'14b54eaf-e63a-7b72-9a82-f11bb533f5e2' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' group by rp.id); +EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff) + VALUES ('21fd24f3-d9c0-fbae-a078-ec3fabcc2b64','14b54eaf-e63a-7b72-9a82-f11bb533f5e2') on conflict on constraint uniq_staffreportperiod_cal do nothing; +EXEC: update hotelplacedarme.staffreportperiod set maxdays=23,contracthours='184:00:00' where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and id_reportperiod='a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4'; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperiod set maxdays=20,contracthours='160:00:00' where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and id_reportperiod='21fd24f3-d9c0-fbae-a078-ec3fabcc2b64'; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64') + where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and pd.daydate between date('2022-02-01') and date('2022-02-28') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffvacancyyear (id_staff,vacyear) + select id_staff,to_char(daydate,'YYYY')::int4 as vyear from hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' group by id_staff,vyear order by id_staff,vyear + on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'14b54eaf-e63a-7b72-9a82-f11bb533f5e2' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' group by rp.id); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'14b54eaf-e63a-7b72-9a82-f11bb533f5e2' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' group by rp.id); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64') + where pd.id_staff='14b54eaf-e63a-7b72-9a82-f11bb533f5e2' and pd.daydate between date('2022-02-01') and date('2022-02-28') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'4067ca66-58fe-01ca-1cbb-78e321010c20' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' group by rp.id); +EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff) + VALUES ('a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4','4067ca66-58fe-01ca-1cbb-78e321010c20') on conflict on constraint uniq_staffreportperiod_cal do nothing; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'4067ca66-58fe-01ca-1cbb-78e321010c20' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' group by rp.id); +EXEC: INSERT INTO hotelplacedarme.staffreportperiod (id_reportperiod, id_staff) + VALUES ('21fd24f3-d9c0-fbae-a078-ec3fabcc2b64','4067ca66-58fe-01ca-1cbb-78e321010c20') on conflict on constraint uniq_staffreportperiod_cal do nothing; +EXEC: update hotelplacedarme.staffreportperiod set maxdays=21,contracthours='168:00:00' where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and id_reportperiod='a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4'; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperiod set maxdays=20,contracthours='160:00:00' where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and id_reportperiod='21fd24f3-d9c0-fbae-a078-ec3fabcc2b64'; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64') + where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and pd.daydate between date('2022-02-01') and date('2022-02-28') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffvacancyyear (id_staff,vacyear) + select id_staff,to_char(daydate,'YYYY')::int4 as vyear from hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' group by id_staff,vyear order by id_staff,vyear + on conflict on constraint staffvacancyyear_id_staff_vacyear_key do nothing; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'4067ca66-58fe-01ca-1cbb-78e321010c20' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' group by rp.id); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.staffreportperioddays (daydate,id_staff,payedpause,wdcontracthours) +SELECT date_trunc('day', dd)::date as daydate,'4067ca66-58fe-01ca-1cbb-78e321010c20' as id_staff, null as payedpause, + '08:00:00' as wdcontracthours +FROM generate_series( '2021-12-27'::timestamp,'2022-03-06'::timestamp,'1 day'::interval) dd on conflict on constraint uniq_staffworplan_staffday +do update set wdcontracthours = '08:00:00'; +EXEC: DELETE FROM hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and (daydate > date('2022-03-06') or daydate < date('2021-12-27')) + OR (id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' AND daydate not between date('2021-12-27') and date('2022-03-06')); +EXEC: delete from hotelplacedarme.staffreportperiod sp where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and id_reportperiod not in ( +select rp.id from hotelplacedarme.reportperiod rp left join hotelplacedarme.staffreportperioddays pd on (pd.daydate between rp.startdate and rp.enddate) +where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' group by rp.id); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and daydate between date(date_trunc('week',date('2022-02-01'))) and date(date_trunc('week',date('2022-02-28')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = '21fd24f3-d9c0-fbae-a078-ec3fabcc2b64') + where pd.id_staff='4067ca66-58fe-01ca-1cbb-78e321010c20' and pd.daydate between date('2022-02-01') and date('2022-02-28') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: insert into hotelplacedarme.workplandays (id_workplan,weeknum,weekday) values ('87b492b8-d8b9-58bf-a33e-8704bbf02d46',1,1),('87b492b8-d8b9-58bf-a33e-8704bbf02d46',1,2),('87b492b8-d8b9-58bf-a33e-8704bbf02d46',1,3),('87b492b8-d8b9-58bf-a33e-8704bbf02d46',1,4),('87b492b8-d8b9-58bf-a33e-8704bbf02d46',1,5),('87b492b8-d8b9-58bf-a33e-8704bbf02d46',1,6),('87b492b8-d8b9-58bf-a33e-8704bbf02d46',1,7); +EXEC: UPDATE hotelplacedarme.workplandays SET start1='10:00', end1='14:30', start2='18:30', end2='23:00', pause='01:00', pausestart1='14:30', pauseend1='15:00', pausestart2='18:00', pauseend2='18:30' WHERE id='42821461-29d4-172f-acc1-92b3a1267a09'; +EXEC: UPDATE hotelplacedarme.workplans SET weekhours='08:00:00', weekdays=1, freeweekdayslist='["2","3","4","5","6","7"]' WHERE id='87b492b8-d8b9-58bf-a33e-8704bbf02d46' +EXEC: UPDATE hotelplacedarme.workplandays SET start1='15:00', end1='23:45', start2=null, end2=null, pause='00:45', pausestart1='18:00', pauseend1='18:45', pausestart2=null, pauseend2=null WHERE id='2bcb11d6-3ff6-c50d-cd2d-c5e18625a78d'; +EXEC: UPDATE hotelplacedarme.workplans SET weekhours='16:00:00', weekdays=2, freeweekdayslist='["3","4","5","6","7"]' WHERE id='87b492b8-d8b9-58bf-a33e-8704bbf02d46' +EXEC: update hotelplacedarme.workplandays set start1='10:00:00',end1='14:30:00',start2='18:30:00',end2='23:00:00', pause='01:00:00',pausestart1='14:30:00',pauseend1='15:00:00',pausestart2='18:00:00',pauseend2='18:30:00' where id='6ecb801e-e22e-0929-36ff-1f5f6c240656'; +EXEC: update hotelplacedarme.workplandays set start1='10:00:00',end1='14:30:00',start2='18:30:00',end2='23:00:00', pause='01:00:00',pausestart1='14:30:00',pauseend1='15:00:00',pausestart2='18:00:00',pauseend2='18:30:00' where id='b8fe5978-7738-8cc5-dc6b-ee185bc7199f'; +EXEC: update hotelplacedarme.workplandays set start1='15:00:00',end1='23:45:00',start2=null,end2=null, pause='00:45:00',pausestart1='18:00:00',pauseend1='18:45:00',pausestart2=null,pauseend2=null where id='c3ff2b72-351d-977f-cbc2-80244a53981e'; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='06:00',timeend1='14:45',timestart2=null,timeend2=null,pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='27c5fbb5-6652-5ed8-e20d-7ab64990600c'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2021-12-29') and id not in ('d5c0270b-3a52-c2fe-8e5b-f7aadd3cf4f1'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1='06:00:00', timeend1='14:45:00', timestart2= null, timeend2=null, timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('8ed915d8-32a5-7e02-c8c5-5567af8b8ec7'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('8ed915d8-32a5-7e02-c8c5-5567af8b8ec7') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1 = null, timeend1 =null, timestart2 = null, timeend2 = null, pausestart1 = null, pauseend1 =null, pausestart2 = null, pauseend2 = null, timepause = null, vacancyhours = null, vacillhours = null, vacextrahours = null, otherpaidhours = null, partunemplhours= null, recuperationhours = null, workhours=null, dayhours=null,vacancycomment=null,vacillcomment=null,vacextracomment=null,recupcomment=null,otherpaidhourscomment=null,partunempcomment=null where id in ('27c5fbb5-6652-5ed8-e20d-7ab64990600c'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('27c5fbb5-6652-5ed8-e20d-7ab64990600c') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1=null, timeend1=null, timestart2= null, timeend2=null, timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('8ed915d8-32a5-7e02-c8c5-5567af8b8ec7'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('8ed915d8-32a5-7e02-c8c5-5567af8b8ec7') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1=null, timeend1=null, timestart2= null, timeend2=null, timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('8ed915d8-32a5-7e02-c8c5-5567af8b8ec7'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('8ed915d8-32a5-7e02-c8c5-5567af8b8ec7') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1=null, timeend1=null, timestart2= null, timeend2=null, timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('8ed915d8-32a5-7e02-c8c5-5567af8b8ec7'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('8ed915d8-32a5-7e02-c8c5-5567af8b8ec7') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1=null, timeend1=null, timestart2= null, timeend2=null, timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('8ed915d8-32a5-7e02-c8c5-5567af8b8ec7'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('8ed915d8-32a5-7e02-c8c5-5567af8b8ec7') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1 = null, timeend1 =null, timestart2 = null, timeend2 = null, pausestart1 = null, pauseend1 =null, pausestart2 = null, pauseend2 = null, timepause = null, vacancyhours = null, vacillhours = null, vacextrahours = null, otherpaidhours = null, partunemplhours= null, recuperationhours = null, workhours=null, dayhours=null,vacancycomment=null,vacillcomment=null,vacextracomment=null,recupcomment=null,otherpaidhourscomment=null,partunempcomment=null where id in ('27c5fbb5-6652-5ed8-e20d-7ab64990600c'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('27c5fbb5-6652-5ed8-e20d-7ab64990600c') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='08:00',timeend1='14:45',timestart2=null,timeend2=null,pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='27c5fbb5-6652-5ed8-e20d-7ab64990600c'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2021-12-29') and id not in ('d5c0270b-3a52-c2fe-8e5b-f7aadd3cf4f1'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1='08:00:00', timeend1='14:45:00', timestart2= null, timeend2=null, timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('8ed915d8-32a5-7e02-c8c5-5567af8b8ec7'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('8ed915d8-32a5-7e02-c8c5-5567af8b8ec7') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1 = null, timeend1 =null, timestart2 = null, timeend2 = null, pausestart1 = null, pauseend1 =null, pausestart2 = null, pauseend2 = null, timepause = null, vacancyhours = null, vacillhours = null, vacextrahours = null, otherpaidhours = null, partunemplhours= null, recuperationhours = null, workhours=null, dayhours=null,vacancycomment=null,vacillcomment=null,vacextracomment=null,recupcomment=null,otherpaidhourscomment=null,partunempcomment=null where id in ('27c5fbb5-6652-5ed8-e20d-7ab64990600c'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('27c5fbb5-6652-5ed8-e20d-7ab64990600c') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='06:00',timeend1='14:45',timestart2=null,timeend2=null,pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='8ed915d8-32a5-7e02-c8c5-5567af8b8ec7'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2022-01-03') and id not in ('995c3aca-6068-3bad-4d4b-53ca54304dee'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1='06:00:00', timeend1='14:45:00', timestart2= null, timeend2=null, timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('09239728-30b0-9a1e-f0d5-44f2799cd539'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('09239728-30b0-9a1e-f0d5-44f2799cd539') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1='06:00:00', timeend1='14:45:00', timestart2= null, timeend2=null, timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('fa3ba8a0-8d0d-fcba-ac63-0d0c0bbda0d3'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('fa3ba8a0-8d0d-fcba-ac63-0d0c0bbda0d3') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='06:00',timeend1='14:30',timestart2=null,timeend2=null,pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='09239728-30b0-9a1e-f0d5-44f2799cd539'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2022-01-04') and id not in ('481c4e96-0cbb-db56-87f9-c9883ec5c425'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='06:00',timeend1='14:30',timestart2=null,timeend2=null,pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='fa3ba8a0-8d0d-fcba-ac63-0d0c0bbda0d3'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2022-01-05') and id not in ('acc9c6a9-c574-3cc7-2861-6fd3c98737ce'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='10:00',timeend1='14:30',timestart2='18:30',timeend2='23:00',pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='7cef9092-3fa7-edf7-7498-5780fc493dab'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2022-01-08') and id not in ('95266fa0-a445-02ba-f4f7-8db6a6f76396'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=0,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='15:00',timeend1='23:45',timestart2=null,timeend2=null,pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='9a660396-b21e-e809-5f68-10fd7d0075df'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2022-01-09') and id not in ('2b6f457e-141c-2c3b-dbfc-e273f84f2c25'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=0,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1='10:00:00', timeend1='14:30:00', timestart2= '18:30:00', timeend2='23:00:00', timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('f315c3da-946b-4ca0-7edb-472894284a7d'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('f315c3da-946b-4ca0-7edb-472894284a7d') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-17'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-17'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1='15:00:00', timeend1='23:45:00', timestart2= null, timeend2=null, timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('f216ecb3-4a77-66e1-c16a-37868d3395ce'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('f216ecb3-4a77-66e1-c16a-37868d3395ce') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-17'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-17'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1='10:00:00', timeend1='14:30:00', timestart2= '18:30:00', timeend2='23:00:00', timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('ead44f77-116b-5f7f-8bea-86f580a530e8','4bd516eb-8cbf-5d8d-d391-331c68f16a1d'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('ead44f77-116b-5f7f-8bea-86f580a530e8','4bd516eb-8cbf-5d8d-d391-331c68f16a1d') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=0,last44date=date('2022-01-17'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=0,last44date=date('2022-01-17'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1='15:00:00', timeend1='23:45:00', timestart2= null, timeend2=null, timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('3f9ba3ab-0694-d025-5e9c-9dc4a6914caa'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('3f9ba3ab-0694-d025-5e9c-9dc4a6914caa') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=0,last44date=date('2022-01-17'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=0,last44date=date('2022-01-17'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1='10:00:00', timeend1='14:30:00', timestart2= '18:30:00', timeend2='23:00:00', timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('2e682993-c269-51f0-4d30-4c2db2d5e762','2899eda8-0686-d58e-b9a4-4c09f64ece7f','6d25ffcd-6ec2-3829-8c95-fa3ddb64a5f8'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('2e682993-c269-51f0-4d30-4c2db2d5e762','2899eda8-0686-d58e-b9a4-4c09f64ece7f','6d25ffcd-6ec2-3829-8c95-fa3ddb64a5f8') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=0,last44date=date('2022-01-24'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=0,last44date=date('2022-01-24'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1 = null, timeend1 =null, timestart2 = null, timeend2 = null, pausestart1 = null, pauseend1 =null, pausestart2 = null, pauseend2 = null, timepause = null, vacancyhours = null, vacillhours = null, vacextrahours = null, otherpaidhours = null, partunemplhours= null, recuperationhours = null, workhours=null, dayhours=null,vacancycomment=null,vacillcomment=null,vacextracomment=null,recupcomment=null,otherpaidhourscomment=null,partunempcomment=null where id in ('2899eda8-0686-d58e-b9a4-4c09f64ece7f'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('2899eda8-0686-d58e-b9a4-4c09f64ece7f') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=0,last44date=date('2022-01-24'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=0,last44date=date('2022-01-24'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='10:00',timeend1='14:30',timestart2='18:30',timeend2='23:00',pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours='08:00',vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='2899eda8-0686-d58e-b9a4-4c09f64ece7f'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2022-01-21') and id not in ('df2117f0-b3a3-3ebf-e727-3de88bb88003'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=0,last44date=date('2022-01-24'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1 = null, timeend1 =null, timestart2 = null, timeend2 = null, pausestart1 = null, pauseend1 =null, pausestart2 = null, pauseend2 = null, timepause = null, vacancyhours = null, vacillhours = null, vacextrahours = null, otherpaidhours = null, partunemplhours= null, recuperationhours = null, workhours=null, dayhours=null,vacancycomment=null,vacillcomment=null,vacextracomment=null,recupcomment=null,otherpaidhourscomment=null,partunempcomment=null where id in ('2899eda8-0686-d58e-b9a4-4c09f64ece7f'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('2899eda8-0686-d58e-b9a4-4c09f64ece7f') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=0,last44date=date('2022-01-24'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=0,last44date=date('2022-01-24'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1=null,timeend1=null,timestart2=null,timeend2=null,pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours='08:00',vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='2899eda8-0686-d58e-b9a4-4c09f64ece7f'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2022-01-21') and id not in ('df2117f0-b3a3-3ebf-e727-3de88bb88003'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-24'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='10:00',timeend1='18:45',timestart2=null,timeend2=null,pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='106f81fb-df7e-41dd-6107-44043886d600'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2022-01-18') and id not in ('82064209-dded-589c-4426-69cde5859a80'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-24'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1='15:00:00', timeend1='23:45:00', timestart2= null, timeend2=null, timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('1ad3ae56-459b-0fc7-89f3-41e61532f3bd'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('1ad3ae56-459b-0fc7-89f3-41e61532f3bd') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=3,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-24'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=3,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-24'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1='10:00:00', timeend1='14:30:00', timestart2= '18:30:00', timeend2='23:00:00', timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('c4149aba-7ed6-523c-286a-8ccde9a0ede9'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('c4149aba-7ed6-523c-286a-8ccde9a0ede9') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=3,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=3,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1='15:00:00', timeend1='23:45:00', timestart2= null, timeend2=null, timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('46e7c116-d7d4-d824-68f8-47ef6cfac410','ac7083e4-19c5-d224-47f0-399b557b2792','3a74db40-6a2d-5efb-c3be-1ca21e25979f','f806b869-9ae6-6b70-fe9b-345ddff90a44'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('46e7c116-d7d4-d824-68f8-47ef6cfac410','ac7083e4-19c5-d224-47f0-399b557b2792','3a74db40-6a2d-5efb-c3be-1ca21e25979f','f806b869-9ae6-6b70-fe9b-345ddff90a44') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1='10:00:00', timeend1='14:30:00', timestart2= '18:30:00', timeend2='23:00:00', timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('e3f4112a-94b2-1ead-1f3a-ac608fea204a','474a18e1-f919-7d67-17f8-04be6e0e284f','b19f26b5-ff93-102d-2116-6dcc70837db3'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('e3f4112a-94b2-1ead-1f3a-ac608fea204a','474a18e1-f919-7d67-17f8-04be6e0e284f','b19f26b5-ff93-102d-2116-6dcc70837db3') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1='10:00:00', timeend1='14:30:00', timestart2= '18:30:00', timeend2='23:00:00', timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('4521fe02-581f-6184-39d6-c69ef3dc9526'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('4521fe02-581f-6184-39d6-c69ef3dc9526') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='12:00',timeend1='20:45',timestart2=null,timeend2=null,pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='a43190ec-87cc-e088-01dd-bab78db42043'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2022-02-04') and id not in (''); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='10:00',timeend1='14:30',timestart2='18:30',timeend2='23:00',pausestart1='14:00',pauseend1='14:30',pausestart2='18:30',pauseend2='19:00',payedpause=null,timepause='01:00',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='2e682993-c269-51f0-4d30-4c2db2d5e762'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2022-01-17') and id not in ('f749809f-b012-a59a-7501-1ae2af55b43d'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1='10:00:00', timeend1='14:30:00', timestart2= '18:30:00', timeend2='23:00:00', timepause='01:00:00', pausestart1='14:00:00', pauseend1='14:30:00', pausestart2='18:30:00', pauseend2='19:00:00', vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('4bd516eb-8cbf-5d8d-d391-331c68f16a1d','ead44f77-116b-5f7f-8bea-86f580a530e8','f315c3da-946b-4ca0-7edb-472894284a7d','7cef9092-3fa7-edf7-7498-5780fc493dab','6d25ffcd-6ec2-3829-8c95-fa3ddb64a5f8','c4149aba-7ed6-523c-286a-8ccde9a0ede9','e3f4112a-94b2-1ead-1f3a-ac608fea204a','474a18e1-f919-7d67-17f8-04be6e0e284f','4521fe02-581f-6184-39d6-c69ef3dc9526','b19f26b5-ff93-102d-2116-6dcc70837db3'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('4bd516eb-8cbf-5d8d-d391-331c68f16a1d','ead44f77-116b-5f7f-8bea-86f580a530e8','f315c3da-946b-4ca0-7edb-472894284a7d','7cef9092-3fa7-edf7-7498-5780fc493dab','6d25ffcd-6ec2-3829-8c95-fa3ddb64a5f8','c4149aba-7ed6-523c-286a-8ccde9a0ede9','e3f4112a-94b2-1ead-1f3a-ac608fea204a','474a18e1-f919-7d67-17f8-04be6e0e284f','4521fe02-581f-6184-39d6-c69ef3dc9526','b19f26b5-ff93-102d-2116-6dcc70837db3') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='06:00',timeend1='14:45',timestart2=null,timeend2=null,pausestart1='11:30',pauseend1='12:15',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:45',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='8ed915d8-32a5-7e02-c8c5-5567af8b8ec7'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2022-01-03') and id not in ('995c3aca-6068-3bad-4d4b-53ca54304dee'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='06:00',timeend1='14:30',timestart2=null,timeend2=null,pausestart1='11:30',pauseend1='12:15',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:45',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='09239728-30b0-9a1e-f0d5-44f2799cd539'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2022-01-04') and id not in ('481c4e96-0cbb-db56-87f9-c9883ec5c425'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1='06:00:00', timeend1='14:30:00', timestart2= null, timeend2=null, timepause='00:45:00', pausestart1='11:30:00', pauseend1='12:15:00', pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('fa3ba8a0-8d0d-fcba-ac63-0d0c0bbda0d3'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('fa3ba8a0-8d0d-fcba-ac63-0d0c0bbda0d3') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='15:00',timeend1='23:45',timestart2=null,timeend2=null,pausestart1='18:00',pauseend1='18:45',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:45',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='f216ecb3-4a77-66e1-c16a-37868d3395ce'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2022-01-11') and id not in ('9e5bd644-2867-bc2c-4672-67e59482e192'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1='15:00:00', timeend1='23:45:00', timestart2= null, timeend2=null, timepause='00:45:00', pausestart1='18:00:00', pauseend1='18:45:00', pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('9a660396-b21e-e809-5f68-10fd7d0075df','3f9ba3ab-0694-d025-5e9c-9dc4a6914caa','1ad3ae56-459b-0fc7-89f3-41e61532f3bd','ac7083e4-19c5-d224-47f0-399b557b2792','3a74db40-6a2d-5efb-c3be-1ca21e25979f','f806b869-9ae6-6b70-fe9b-345ddff90a44'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('9a660396-b21e-e809-5f68-10fd7d0075df','3f9ba3ab-0694-d025-5e9c-9dc4a6914caa','1ad3ae56-459b-0fc7-89f3-41e61532f3bd','ac7083e4-19c5-d224-47f0-399b557b2792','3a74db40-6a2d-5efb-c3be-1ca21e25979f','f806b869-9ae6-6b70-fe9b-345ddff90a44') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='10:00',timeend1='18:45',timestart2=null,timeend2=null,pausestart1='13:00',pauseend1='13:45',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:45',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='106f81fb-df7e-41dd-6107-44043886d600'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2022-01-18') and id not in ('82064209-dded-589c-4426-69cde5859a80'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='15:00',timeend1='23:45',timestart2=null,timeend2=null,pausestart1='18:00',pauseend1='18:30',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:30',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='46e7c116-d7d4-d824-68f8-47ef6cfac410'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2022-01-25') and id not in ('ed79b0e6-0f25-3c44-9395-d23a6874ce69'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='15:00',timeend1='23:45',timestart2=null,timeend2=null,pausestart1='18:00',pauseend1='18:45',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:45',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='46e7c116-d7d4-d824-68f8-47ef6cfac410'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2022-01-25') and id not in ('ed79b0e6-0f25-3c44-9395-d23a6874ce69'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='12:00',timeend1='20:45',timestart2=null,timeend2=null,pausestart1='17:00',pauseend1='17:45',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:45',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='a43190ec-87cc-e088-01dd-bab78db42043'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate=date('2022-02-04') and id not in (''); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=4,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='b0dba065-1542-4579-18c7-d821a1da7a4b' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='06:00',timeend1='14:45',timestart2=null,timeend2=null,pausestart1='11:15',pauseend1='12:00',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:45',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='e813646e-0918-c64f-6c0d-fd870020db65'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate=date('2022-01-03') and id not in ('95f4dea7-85de-08fe-8d4a-f27b2d4497c0'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1 = null, timeend1 =null, timestart2 = null, timeend2 = null, pausestart1 = null, pauseend1 =null, pausestart2 = null, pauseend2 = null, timepause = null, vacancyhours = null, vacillhours = null, vacextrahours = null, otherpaidhours = null, partunemplhours= null, recuperationhours = null, workhours=null, dayhours=null,vacancycomment=null,vacillcomment=null,vacextracomment=null,recupcomment=null,otherpaidhourscomment=null,partunempcomment=null where id in ('e813646e-0918-c64f-6c0d-fd870020db65'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('e813646e-0918-c64f-6c0d-fd870020db65') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1='10:00:00', timeend1='14:30:00', timestart2= '18:30:00', timeend2='23:00:00', timepause='01:00:00', pausestart1='14:00:00', pauseend1='14:30:00', pausestart2='18:30:00', pauseend2='19:00:00', vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('8475980f-e1ca-1605-dc07-5eb6696f1ffd','965dec45-c4e4-39c3-dd92-6b6cb1a72f6f','31f9ac33-74eb-66ba-8fa8-d6dce320cd7a','61048838-8258-1137-2135-746dc1bdb0f1','472e8269-88ec-ac5e-dc7e-f0f0a190bb70','b79dd423-dbb5-1919-3c63-149dcc7b70e9','927497d2-c268-e4f7-bddc-19a42e430e20','c690c0f3-8685-9675-6ab3-8f2140054d7a','f86ce384-5a91-8d65-47f6-ce58426a3afb','8325f6e3-3f60-4b57-f945-4e8f28c797d7','31c222c6-917f-eeab-38e0-94b2dd5354b7','b4d41750-f216-d38c-9d83-10f34ee4ae97'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('8475980f-e1ca-1605-dc07-5eb6696f1ffd','965dec45-c4e4-39c3-dd92-6b6cb1a72f6f','31f9ac33-74eb-66ba-8fa8-d6dce320cd7a','61048838-8258-1137-2135-746dc1bdb0f1','472e8269-88ec-ac5e-dc7e-f0f0a190bb70','b79dd423-dbb5-1919-3c63-149dcc7b70e9','927497d2-c268-e4f7-bddc-19a42e430e20','c690c0f3-8685-9675-6ab3-8f2140054d7a','f86ce384-5a91-8d65-47f6-ce58426a3afb','8325f6e3-3f60-4b57-f945-4e8f28c797d7','31c222c6-917f-eeab-38e0-94b2dd5354b7','b4d41750-f216-d38c-9d83-10f34ee4ae97') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='10:00',timeend1='18:45',timestart2=null,timeend2=null,pausestart1='15:00',pauseend1='15:45',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:45',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='5e354027-a6c8-3164-812a-df798794655e'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate=date('2022-01-05') and id not in ('f4abee17-6eb7-ccc8-f080-206e42bef506'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1=null,timeend1=null,timestart2=null,timeend2=null,pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours='08:00',vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='21bf469a-05db-1574-9747-cfece644be53'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate=date('2022-01-07') and id not in ('67f24c35-57fa-8778-b9a7-cfd393887c47'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1=null, timeend1=null, timestart2= null, timeend2=null, timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours='08:00:00', vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('ea7781b9-8eab-9204-8e19-6735f95e0f7f'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('ea7781b9-8eab-9204-8e19-6735f95e0f7f') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1=null, timeend1=null, timestart2= null, timeend2=null, timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours='08:00:00', vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('c724d7e5-cea8-c118-bb62-af9985cd8736','cf7d1836-55fc-7ebd-7b0a-dc835dff9ad3'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('c724d7e5-cea8-c118-bb62-af9985cd8736','cf7d1836-55fc-7ebd-7b0a-dc835dff9ad3') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='15:00',timeend1='23:45',timestart2=null,timeend2=null,pausestart1='18:00',pauseend1='18:45',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:45',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='5f0e4f42-ef1a-730c-be17-4bc6457ca614'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate=date('2022-01-20') and id not in ('f6e56b7f-c143-d14b-b7cb-6d24c36c81e0'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1='15:00:00', timeend1='23:45:00', timestart2= null, timeend2=null, timepause='00:45:00', pausestart1='18:00:00', pauseend1='18:45:00', pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('91b52e98-259a-8a49-9c5c-4b47fa52cd53'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('91b52e98-259a-8a49-9c5c-4b47fa52cd53') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='12:00',timeend1='20:45',timestart2=null,timeend2=null,pausestart1='16:00',pauseend1='16:45',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:45',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='a2923ddb-89a7-d52d-bad0-9b594b2bc352'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate=date('2022-01-22') and id not in ('d7b714f7-11c9-61eb-474e-8825c176181c'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='15:00',timeend1='23:45',timestart2=null,timeend2=null,pausestart1='18:00',pauseend1='18:45',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:45',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='5f0e4f42-ef1a-730c-be17-4bc6457ca614'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate=date('2022-01-20') and id not in ('f6e56b7f-c143-d14b-b7cb-6d24c36c81e0'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1='15:00:00', timeend1='23:45:00', timestart2= null, timeend2=null, timepause='00:45:00', pausestart1='18:00:00', pauseend1='18:45:00', pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('d38fa95d-e8b6-04c6-9091-8e53ac590250'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('d38fa95d-e8b6-04c6-9091-8e53ac590250') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1='12:00:00', timeend1='20:45:00', timestart2= null, timeend2=null, timepause='00:45:00', pausestart1='16:00:00', pauseend1='16:45:00', pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('b47d8524-1ee2-5651-073b-9d23376da041'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('b47d8524-1ee2-5651-073b-9d23376da041') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1='15:00:00', timeend1='23:45:00', timestart2= null, timeend2=null, timepause='00:45:00', pausestart1='18:00:00', pauseend1='18:45:00', pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('3661ef2a-4d38-c10f-b9a8-0f49a9d2fb7b','63394bfc-767a-962f-f95d-f5242a7f4663'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('3661ef2a-4d38-c10f-b9a8-0f49a9d2fb7b','63394bfc-767a-962f-f95d-f5242a7f4663') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1='15:00:00', timeend1='23:45:00', timestart2= null, timeend2=null, timepause='00:45:00', pausestart1='18:00:00', pauseend1='18:45:00', pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('a2923ddb-89a7-d52d-bad0-9b594b2bc352'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('a2923ddb-89a7-d52d-bad0-9b594b2bc352') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='12:00',timeend1='20:45',timestart2=null,timeend2=null,pausestart1='17:00',pauseend1='17:45',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:45',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='a2923ddb-89a7-d52d-bad0-9b594b2bc352'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate=date('2022-01-22') and id not in ('d7b714f7-11c9-61eb-474e-8825c176181c'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1='12:00:00', timeend1='20:45:00', timestart2= null, timeend2=null, timepause='00:45:00', pausestart1='17:00:00', pauseend1='17:45:00', pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('1c2cf2ef-f271-996e-2ce8-72a3538944f1'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('1c2cf2ef-f271-996e-2ce8-72a3538944f1') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='083eb8a2-1bb3-abca-25fb-ce5939d99398' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='06:00',timeend1='14:30',timestart2=null,timeend2=null,pausestart1='11:00',pauseend1='11:45',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:45',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='91d20887-1175-22a9-a079-0a78514f4580'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate=date('2022-02-04') and id not in (''); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1='06:00:00', timeend1='14:30:00', timestart2= null, timeend2=null, timepause='00:45:00', pausestart1='11:00:00', pauseend1='11:45:00', pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('9a6639be-f4ab-fbd5-69fa-57bc901dce62','4b6ccc2c-e77b-73c1-0217-c3d35545ed87','eddb2037-2b36-3a80-cc56-419b593e8e1d'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('9a6639be-f4ab-fbd5-69fa-57bc901dce62','4b6ccc2c-e77b-73c1-0217-c3d35545ed87','eddb2037-2b36-3a80-cc56-419b593e8e1d') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1=null,timeend1=null,timestart2=null,timeend2=null,pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours='08:00',partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='07889e76-4636-a385-6e5a-6165db1aec00'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate=date('2022-01-31') and id not in (''); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=null,last44date=null,avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1='06:00:00', timeend1='14:30:00', timestart2= null, timeend2=null, timepause='00:45:00', pausestart1='11:00:00', pauseend1='11:45:00', pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('b40f1098-ea3b-9143-cd6a-3c3b5f621aad','4ed389d1-77aa-d7d7-bae2-8fc0c87cc78a','52c11a2b-2eba-700b-c463-8fa6ed8e3816','ef475d0b-b1ca-efe1-cab8-c1473303d5c9','48a930d6-08f3-903b-1a0d-9bad35377e1a','0c5b77cb-4680-2b12-85de-00abae349ced','9c2b2f39-65b3-06df-5f63-c49c76f2ec3d','a2e6640b-9aad-7626-d3bf-e4655a39b4bc','01f7c84f-0812-7992-08e6-711ad9e60858','5013386b-34fb-bff2-f299-2ff6882c1ece','b83a6f14-374c-d2dc-5d24-c0192c11b214','a82c0aa3-c869-6271-d8bd-190b3dabcab3'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('b40f1098-ea3b-9143-cd6a-3c3b5f621aad','4ed389d1-77aa-d7d7-bae2-8fc0c87cc78a','52c11a2b-2eba-700b-c463-8fa6ed8e3816','ef475d0b-b1ca-efe1-cab8-c1473303d5c9','48a930d6-08f3-903b-1a0d-9bad35377e1a','0c5b77cb-4680-2b12-85de-00abae349ced','9c2b2f39-65b3-06df-5f63-c49c76f2ec3d','a2e6640b-9aad-7626-d3bf-e4655a39b4bc','01f7c84f-0812-7992-08e6-711ad9e60858','5013386b-34fb-bff2-f299-2ff6882c1ece','b83a6f14-374c-d2dc-5d24-c0192c11b214','a82c0aa3-c869-6271-d8bd-190b3dabcab3') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1=null,timeend1=null,timestart2=null,timeend2=null,pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours='08:00',vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='05a1be86-a773-3fde-29e2-a32f589405cb'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate=date('2022-01-05') and id not in ('9816f86b-0f7d-1db0-3123-c446bfacc657'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1=null, timeend1=null, timestart2= null, timeend2=null, timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours='08:00:00', vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('b69c46c0-ab03-8172-83cf-38401a42d77c'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('b69c46c0-ab03-8172-83cf-38401a42d77c') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1=null, timeend1=null, timestart2= null, timeend2=null, timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours='08:00:00', vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('be69969d-c4b1-5a4d-03d6-8fcd6fa8d66e','4b0c5619-d9c5-bbd5-47ab-a7a65ff79142','1814c770-cafc-321b-c30d-0873df9b9d7d','cd9d1768-d81a-1368-50cc-100549a394f8','8bcd15b6-b616-3516-2347-cdb972e5985c'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('be69969d-c4b1-5a4d-03d6-8fcd6fa8d66e','4b0c5619-d9c5-bbd5-47ab-a7a65ff79142','1814c770-cafc-321b-c30d-0873df9b9d7d','cd9d1768-d81a-1368-50cc-100549a394f8','8bcd15b6-b616-3516-2347-cdb972e5985c') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='06:00',timeend1='10:00',timestart2=null,timeend2=null,pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours='04:00',partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='6a443826-2784-822e-4fc0-c8982269d19c'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate=date('2022-01-28') and id not in (''); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='57a7e41e-2836-64b4-634a-14d90466b457' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1=null,timeend1=null,timestart2=null,timeend2=null,pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours='08:00',vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='cd2d012d-bb1f-7ab1-eed3-49f3f0903df6'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate=date('2022-01-03') and id not in ('0b7aed2a-2176-2e2c-e3a1-7c9c8cd75108'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1=null, timeend1=null, timestart2= null, timeend2=null, timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours='08:00:00', vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('e764c284-aa84-03b4-711a-d34e1513fc45','ed80b3d7-16b0-8fb3-11ac-0d9ff540b402','055227a1-d92d-1384-430e-bb7659bd3b9c','9be55577-1180-d312-6492-4df6b0f3acfe'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('e764c284-aa84-03b4-711a-d34e1513fc45','ed80b3d7-16b0-8fb3-11ac-0d9ff540b402','055227a1-d92d-1384-430e-bb7659bd3b9c','9be55577-1180-d312-6492-4df6b0f3acfe') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=1,last44date=date('2022-01-10'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1='06:00:00', timeend1='14:30:00', timestart2= null, timeend2=null, timepause='00:45:00', pausestart1='11:00:00', pauseend1='11:45:00', pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('b88eaeb3-8acf-9651-a795-c5c2b47d992c','12aee72a-dce8-24e4-2213-b0eb6b736808','55cbaa81-c4b1-6fdb-19ae-7e8bcb3d59d1'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('b88eaeb3-8acf-9651-a795-c5c2b47d992c','12aee72a-dce8-24e4-2213-b0eb6b736808','55cbaa81-c4b1-6fdb-19ae-7e8bcb3d59d1') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-17'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-17'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1=null,timeend1=null,timestart2=null,timeend2=null,pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours='08:00',vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='879938d8-78f6-bdd7-6a0e-f1d52846bdc1'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate=date('2022-01-13') and id not in ('38cd262e-5880-109a-24f2-ca7fb7485a9f'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-17'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1=null, timeend1=null, timestart2= null, timeend2=null, timepause=null, pausestart1=null, pauseend1=null, pausestart2=null, pauseend2=null, vacancyhours='08:00:00', vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('4b7e70b8-9e3e-23dd-68a6-adb8c682e393'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('4b7e70b8-9e3e-23dd-68a6-adb8c682e393') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-17'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-17'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='15:00',timeend1='23:45',timestart2=null,timeend2=null,pausestart1='18:00',pauseend1='18:45',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:45',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='6c6bae67-5f87-d6e8-729a-73bccad69b3c'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate=date('2022-01-18') and id not in ('b9e6df98-2ee7-d8f9-21b9-58fff4ea80b8'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-24'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1='15:00:00', timeend1='23:45:00', timestart2= null, timeend2=null, timepause='00:45:00', pausestart1='18:00:00', pauseend1='18:45:00', pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('d44ff13f-6169-532e-e763-02809b1ca9ef'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('d44ff13f-6169-532e-e763-02809b1ca9ef') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-24'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-24'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='18:30',timeend1='23:00',timestart2=null,timeend2=null,pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours='04:00',vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='beb69515-a737-bf7e-e4a3-dbe21dba7880'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate=date('2022-01-17') and id not in ('5623fbb3-42d7-7c56-e067-283b28810196'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-24'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='11:00',timeend1='14:30',timestart2='18:30',timeend2='23:00',pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='6b050a12-c2a4-53ae-d8e4-b3be3c04d8cd'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate=date('2022-01-20') and id not in ('63375e10-42dd-0e4b-0e2f-d4e2490eda1e'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=null,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-24'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='12:00',timeend1='20:45',timestart2=null,timeend2=null,pausestart1='17:00',pauseend1='17:45',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:45',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='00704bdf-4e0c-3ea4-37e1-61cce6edb680'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate=date('2022-01-23') and id not in ('adb58475-48bb-df9d-9ed5-63c3c9a86a0d'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-24'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1='15:00:00', timeend1='23:45:00', timestart2= null, timeend2=null, timepause='00:45:00', pausestart1='18:00:00', pauseend1='18:45:00', pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('66fa9d2b-6d43-128b-adf6-f8c2971356be','29a7598e-2ebe-6ebb-7c13-02b516efeb55'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('66fa9d2b-6d43-128b-adf6-f8c2971356be','29a7598e-2ebe-6ebb-7c13-02b516efeb55') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1='12:00:00', timeend1='20:45:00', timestart2= null, timeend2=null, timepause='00:45:00', pausestart1='17:00:00', pauseend1='17:45:00', pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('925790e4-eef1-c9d9-ca0d-7b62347d8a87'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('925790e4-eef1-c9d9-ca0d-7b62347d8a87') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='10:00',timeend1='14:30',timestart2='18:30',timeend2='23:00',pausestart1=null,pauseend1=null,pausestart2=null,pauseend2=null,payedpause=null,timepause='00:00',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='9744d558-6c12-dab1-b0c0-b0cb48cf4b24'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate=date('2022-01-27') and id not in ('fb33909b-f72a-a937-6cc8-5fd0ea160229'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='10:00',timeend1='14:30',timestart2='18:30',timeend2='23:00',pausestart1='14:00',pauseend1='14:30',pausestart2='18:30',pauseend2='19:00',payedpause=null,timepause='01:00',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='9744d558-6c12-dab1-b0c0-b0cb48cf4b24'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate=date('2022-01-27') and id not in ('fb33909b-f72a-a937-6cc8-5fd0ea160229'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='11:00',timeend1='14:30',timestart2='18:30',timeend2='23:00',pausestart1='14:00',pauseend1='14:30',pausestart2='18:30',pauseend2='19:00',payedpause=null,timepause='01:00',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='6b050a12-c2a4-53ae-d8e4-b3be3c04d8cd'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate=date('2022-01-20') and id not in ('63375e10-42dd-0e4b-0e2f-d4e2490eda1e'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=1,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=3,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: UPDATE hotelplacedarme.staffreportperioddays SET timestart1='09:00',timeend1='17:45',timestart2=null,timeend2=null,pausestart1='12:00',pauseend1='12:45',pausestart2=null,pauseend2=null,payedpause=null,timepause='00:45',daycomment=null,vacancycomment=null,vacancyhours=null,vacillcomment=null,vacillhours=null,vacextracomment=null,vacextrahours=null,recupcomment=null,recuperationhours=null,partunempcomment=null,partunemplhours=null,otherpaidhourscomment=null,otherpaidhours=null WHERE id='342993d5-9326-39e3-a8ba-a97dc4888bbb'; +EXEC: DELETE FROM hotelplacedarme.timetracker WHERE id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate=date('2022-01-30') and id not in (''); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1='15:00:00', timeend1='23:45:00', timestart2= null, timeend2=null, timepause='00:45:00', pausestart1='18:00:00', pauseend1='18:45:00', pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('6528d50b-d677-0e6b-3369-284c7a1e8692','969d1451-7d84-0773-35d7-23310d88de3d'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('6528d50b-d677-0e6b-3369-284c7a1e8692','969d1451-7d84-0773-35d7-23310d88de3d') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1='12:00:00', timeend1='20:45:00', timestart2= null, timeend2=null, timepause='00:45:00', pausestart1='17:00:00', pauseend1='17:45:00', pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('5cdd5992-f1d3-e78d-7f87-86be3ed51e72'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('5cdd5992-f1d3-e78d-7f87-86be3ed51e72') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1='10:00:00', timeend1='14:30:00', timestart2= '18:30:00', timeend2='23:00:00', timepause='01:00:00', pausestart1='14:00:00', pauseend1='14:30:00', pausestart2='18:30:00', pauseend2='19:00:00', vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('bd07527d-8d59-4548-b7c6-5b9fa18f3139'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('bd07527d-8d59-4548-b7c6-5b9fa18f3139') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays set timestart1='09:00:00', timeend1='17:45:00', timestart2= null, timeend2=null, timepause='00:45:00', pausestart1='12:00:00', pauseend1='12:45:00', pausestart2=null, pauseend2=null, vacancyhours=null, vacillhours=null, vacextrahours=null, otherpaidhours=null, partunemplhours=null, recuperationhours=null, vacancycomment=null, vacillcomment=null, vacextracomment=null, recupcomment=null, otherpaidhourscomment=null, partunempcomment=null where id in ('b9cbdfd4-fe93-2293-e6fd-30f69188dafa'); +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in ('b9cbdfd4-fe93-2293-e6fd-30f69188dafa') + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; +EXEC: update hotelplacedarme.staffreportperioddays spds set + workhours=ds.worktime, timepause=case when ds.timepause::interval > '00:00:00' then ds.timepause else null end, + dayhours=(ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval + ds.partunemplhours )::interval, interruptionhours = ds.interruption , + contracthours=case when ds.worktime::interval + ds.vachours::interval + ds.vacillhours::interval + ds.vacextrahours::interval + ds.otherpaidhours::interval + ds.recup::interval > '00:00:00'::interval then ds.wdcontracthours else null end + from ( + select preds.id,case when preds.recuperationhours is null then '00:00:00'::interval else preds.recuperationhours::interval end as recup, + case when preds.vacancyhours is null then '00:00:00'::time else preds.vacancyhours end as vachours, + case when preds.vacillhours is null then '00:00:00'::time else preds.vacillhours end as vacillhours, + case when preds.vacextrahours is null then '00:00:00'::time else preds.vacextrahours end as vacextrahours, + case when preds.otherpaidhours is null then '00:00:00'::time else preds.otherpaidhours end as otherpaidhours, + case when preds.partunemplhours is null then '00:00:00'::time else preds.partunemplhours end as partunemplhours, + preds.interruption, + (preds.dt1+preds.dt2)-(case when preds.payedpause is null then preds.pdt1+preds.pdt2 else '00:00:00'::interval end) as worktime, + (preds.pdt1+preds.pdt2) as timepause, + wdcontracthours + from ( select id, recuperationhours,vacancyhours,vacillhours,vacextrahours,otherpaidhours,payedpause,partunemplhours, + case when timestart1 is not null and timeend1 is not null then case when timeend1 < timestart1 then '24:00:00'::interval + timeend1 - timestart1 else timeend1 - timestart1 end else '00:00:00'::interval end as dt1, + case when timestart2 is not null and timeend2 is not null then case when timeend2 < timestart2 then '24:00:00'::interval + timeend2 - timestart2 else timeend2 - timestart2 end else '00:00:00'::interval end as dt2, + case when pausestart1 is not null and pauseend1 is not null then case when pauseend1 < pausestart1 then '24:00:00'::interval + pauseend1 - pausestart1 else pauseend1 - pausestart1 end else '00:00:00'::interval end as pdt1, + case when pausestart2 is not null and pauseend2 is not null then case when pauseend2 < pausestart2 then '24:00:00'::interval + pauseend2 - pausestart2 else pauseend2 - pausestart2 end else '00:00:00'::interval end as pdt2, + case when timestart2 is not null and timeend1 is not null and timestart1 is not null and timeend2 is not null then timestart2 - timeend1 else null end as interruption, + wdcontracthours + from hotelplacedarme.staffreportperioddays where id in (select id from hotelplacedarme.staffreportperioddays where id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and daydate between date(date_trunc('week',date('2022-01-01'))) and date(date_trunc('week',date('2022-01-31')) + interval '6 days')) + ) preds) ds where spds.id=ds.id; +EXEC: update hotelplacedarme.staffreportperiod rpd set + --contracthours=csp.contracthours, + workhours=csp.workhours, + vacancyill=csp.vacillhours, + vacancynormal=csp.vacancynormal, + vacancyextra=csp.vacextrahours, + otherpaidhours=csp.otherpaidhours, + partunemplhours=csp.partunemplhours, + totalhours=csp.totalhours, + recuperationhours=csp.recuperationhours,statussuncount=2,suppvacancysunwork=null,suppvacancy44hours=null,status44hcount=2,last44date=date('2022-01-31'),avgtotalweekhours=null,hoursdiff=csp.diffhours + FROM ( + select contracthours,workhours,totalhours,recuperationhours, totalhours-contracthours-transferedhours as diffhours,id,vacillhours,vacancynormal,vacextrahours,otherpaidhours,partunemplhours from ( + select dp.id, + sum(pd.workhours) as workhours, + sum(pd.dayhours) as totalhours, + sum(coalesce(pd.vacancyhours,'00:00:00'::time)) as vacancynormal, + sum(coalesce(pd.vacillhours,'00:00:00'::time)) as vacillhours, + sum(coalesce(pd.vacextrahours,'00:00:00'::time)) as vacextrahours, + sum(coalesce(pd.otherpaidhours,'00:00:00'::time)) as otherpaidhours, + sum(coalesce(pd.partunemplhours,'00:00:00'::time)) as partunemplhours, + sum(coalesce(pd.recuperationhours,'00:00:00'::time)) as recuperationhours, + coalesce(dp.contracthours,'00:00:00'::interval) as contracthours, + coalesce(dp.payedhours0,'00:00:00'::interval) as payedhours0, + coalesce(dp.payedhours40,'00:00:00'::interval) as payedhours40, + coalesce(dp.transferedhours,'00:00:00'::interval) as transferedhours + from hotelplacedarme.staffreportperioddays pd + join hotelplacedarme.staffreportperiod dp on (pd.id_staff=dp.id_staff and dp.id_reportperiod = 'a47cdd08-1edc-16a5-a3c0-d533e2ebf1b4') + where pd.id_staff='79a916f1-ad2c-1189-838d-b150e07fbdb8' and pd.daydate between date('2022-01-01') and date('2022-01-31') + group by dp.id,dp.payedhours,dp.transferedhourscalc + ) rp) csp where csp.id=rpd.id; diff --git a/app/tmpl/block/dlgterms.html b/app/tmpl/block/dlgterms.html new file mode 100644 index 00000000..eafde1c8 --- /dev/null +++ b/app/tmpl/block/dlgterms.html @@ -0,0 +1,17 @@ + \ No newline at end of file diff --git a/app/tmpl/module/index.html b/app/tmpl/module/index.html index 4aa7d677..d4ad1695 100644 --- a/app/tmpl/module/index.html +++ b/app/tmpl/module/index.html @@ -67,23 +67,7 @@ - +{{ include('block/dlgterms.html') }} {{ include('block/dlg_newpassword.html') }} diff --git a/app/tmpl/module/staff/staff.js b/app/tmpl/module/staff/staff.js index 6105940c..42939b97 100644 --- a/app/tmpl/module/staff/staff.js +++ b/app/tmpl/module/staff/staff.js @@ -152,6 +152,7 @@ let staff ={ gettbldata: function(id){ let selectedData = staff.tbl.getSelectedData(); postData("db.php",{ "cl":"Staff","fn":"getStaffList","schema":schemata,"id_groups":'{{session.staffgroups}}'}).then(data => { + console.log("getStaffList",data.result); staff.tbl.setData(data.result.data).then(function(){ if(selectedData[0]){staff.tbl.selectRow(selectedData[0]['id']);} }); @@ -200,12 +201,17 @@ let staff ={ } showdataloaddlg('','
{{ lbl.waitmsg }}
'); postData("db.php",flds).then(data => { + console.log("after Save OK !",data); document.getElementById("dlg_addstaff").style.display = 'none'; staff.current_view = 'basedata'; staff.gettbldata(); staff.setview(staff.current_view); closedataloaddlg(); - }).catch(e => {document.getElementById("dlg_addstaff").style.display = 'none';closedataloaddlg();}); + }).catch(e => { + console.log("after Save Catched !",e); + document.getElementById("dlg_addstaff").style.display = 'none'; + closedataloaddlg(); + }); }, edit: function(){ let udata = staff.tbl.getSelectedData(); diff --git a/app/tmpl/module/workplans/workplans.js b/app/tmpl/module/workplans/workplans.js index 27240e6b..abddbd3b 100644 --- a/app/tmpl/module/workplans/workplans.js +++ b/app/tmpl/module/workplans/workplans.js @@ -289,14 +289,14 @@ let workplans ={ mtp1 = pe1-ps1; //console.log(mtp1); opt1.value=timecalc.MinutesToTime(mtp1); - if (ps1 < s1){ - workplans.disablesave = true; - msg = "les pauses doivent être dans les {{ lbl.workhours }}!"; - } - if (pe1 > e1){ - workplans.disablesave = true; - msg = "les pauses doivent être dans les {{ lbl.workhours }}!"; - } + // if (ps1 < s1){ + // workplans.disablesave = true; + // msg = "les pauses doivent être dans les {{ lbl.workhours }}!"; + // } + // if (pe1 > e1){ + // workplans.disablesave = true; + // msg = "les pauses doivent être dans les {{ lbl.workhours }}!"; + // } } if (ope2.value && ops2.value){ ps2 = timecalc.TimeToMinutes(ops2.value); @@ -304,14 +304,14 @@ let workplans ={ if (pe2 < ps2) {pe2 = pe2 + 1440;} mtp2 = pe2-ps2; opt2.value=timecalc.MinutesToTime(mtp2); - if (ps2 < s2){ - workplans.disablesave = true; - msg = "les pauses doivent être dans les {{ lbl.workhours }}!"; - } - if (pe2 > e2){ - workplans.disablesave = true; - msg = "les pauses doivent être dans les {{ lbl.workhours }}!"; - } + // if (ps2 < s2){ + // workplans.disablesave = true; + // msg = "les pauses doivent être dans les {{ lbl.workhours }}!"; + // } + // if (pe2 > e2){ + // workplans.disablesave = true; + // msg = "les pauses doivent être dans les {{ lbl.workhours }}!"; + // } } if (workplans.disablesave == true){ document.getElementById("workplanday_errmsg").innerHTML = '
'+ msg+'
';